-
Notifications
You must be signed in to change notification settings - Fork 68
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
Should either include a queryset
attribute, or override the get_queryset()
method.
#1
Comments
queryset
attribute, or override the get_queryset()
method.queryset
attribute, or override the get_queryset()
method.
adding
works |
Thanks for catching this problem, @cho-is -- I saw it a couple days ago myself. This problem crept in with DRF 3.3, and I'm gonna release an update today or tomorrow with a very similar patch to the one you proposed |
Just uploaded released a patch that fixes this error (and created a test to confirm the problem and fix). I did not alter the mixin, because I didn't want to make any assumptions about use. The new version is up on pypi or can be downloaded from the releases here. |
It seems to be an issue with DjangoRestMultipleModels and cache. It does not invalidate the cache when you change a model. I think it might be related with
I will take a deeper look. |
The only different thing I found from DRF that your Mixin does not have is:
Do you think this might be why it does not reflect the model changes through the API View when you change a model in the backend? |
Any help would be much appreciated. |
I think that line you found in DRF might be the key, @cho-is -- nice sleuthing. The first thing I would try would be replacing these lines in the multiple model mixin:
with this:
I won't have time to test this in the next few days, but if you try it out, let me know what happens. |
It seems to be working fine now. Many thanks! much appreciated. |
Glad it's fixed. I'll try to update the repo with the changes in the next week or so. |
Hello, I am experiencing caching issues even with this fix. The only way to receive updated results is by changing line 73 in mixins.py:
to this one:
Please, let me know if you need more details from me. |
Hmm, the mixin has gone through some refactoring, and I guess the caching problem snuck back in. Rather than replacing line 73 entirely, does the caching work if you insert your suggested line before, like:
I'd still like to run the queryset through the filter backend, so I don't want to remove that line entirely. Let me know if the above suggestion still fixes the caching issue. |
Thanks for your response. I confirm that doing so still fixes the caching issue. |
Thanks for confirming, @tony47. Fix is now in PyPI. |
We've run into a problem with this - it breaks the ability to cache the querysets and return them from the Code like this used to work:
And mean that subsequent calls to the API would not result in a new DB query. Equivalent code works fine in DRF because the re-evaluation is forced in So the right fix is to move this to the |
holyshit, thanks |
Genius! |
The solution is adding ' ' this in views file. After you have called serializer class like this: that is a solution of our bug!! |
djangorestframework==3.3.1
The text was updated successfully, but these errors were encountered: