Skip to content
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

select_related and prefetch_related should only cache on GET method #3028

Closed
sainttail opened this issue Jun 11, 2015 · 1 comment
Closed

Comments

@sainttail
Copy link

I'm following #1964

by declaring something like queryset = SomeObj.objects.all().prefetch_related('many_object') in Generic Viewset

However this also cache when I patch the object and adding or removing that many_object
so I have to override patch method to called get_object() to refresh in order to get the updated return result

...
instance = self.get_object()
return Response(self.get_serializer(instance).data)

Are there any method to separate this?

@tomchristie
Copy link
Member

Duplicate of #2442. Not a lot we can do about this other than suitable documentation.
You could override get_queryset to only perform the prefetch on GET requests, perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants