New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HttpResponse has no 'data' on 0.4.0 #237
Comments
@codingjoe could you check as you made the change? |
Hi @mbaragiola that looks like it is related to the caching change it did here: I would recommend to disable caching in your test environment. If you want to test the cached behavior, need to be aware the the cached response is a regular Django |
Maybe that should be documented somewhere... but I don't know which place would fit this kind of specialized note. |
you can add a BC breaking note on release note of 0.4.0 |
@auvipy @codingjoe thanks for replying! I'm curious, what's the reason behind this change? Since this is an extension to DRF and not Django itself. Testing cache is critical to me, so I'm trying to find a workaround but I can't so far access serialized data on HttpResponse. |
@codingjoe I also think since it's an extension of drf, we should be able to do so, since its a breaking change, I think if there isn't any workaround for it, we should revert the change. do you have any drfish solution in mind? |
Sorry I need to call for a bit more caution here. Some like – my company included – may already use the improved cache feature. If you revert it now, that could be considered a breaking change as well ;) @mbaragiola to give you a bit more context. Caching a DRF response as is pickling the whole object is not a good idea. The DRF response object is too large and can even include whole Querysets. Form a user perspective this change it totally acceptable and we experienced a >100x improvement on delivery time as well as memory footprint on our caching servers. So this really only breaks your tests, because you assume the response to be a DRF response. I see only possible solutions here, we document that the cache features will return regular HTTPResponses and make sure it is consistent. You will need to adapt your tests then. "Breaking" the cache again, by blowing it up seems not reasonable to me. I also don't really see a way to cache the original DRF response in a way that satisfies the main need of a cache: To be fast. That is of course only my opinion, but I hope it explains my reasoning a bit better. |
If that's truly the case, then I agree @codingjoe. Thank you for explaining! |
@codingjoe could you please send a pr explaining so? |
sure thing, see #240 |
Hey guys, just tried updating to 0.4.0 and it broke all my tests.
Whenever I do a GET to a filtered cached list, I run the following test to check wether the amount of objects returned is ok:
But now I get the following error:
AttributeError: 'HttpResponse' object has no attribute 'data'
Django is 1.11.15, DRF is 3.8.2 and Python is 3.6 (haven't changed their versions, just
drf-extensions
).Thanks in advance!
EDIT: Forgot to mention this is a cached list.
The text was updated successfully, but these errors were encountered: