Skip to content

select_related and prefetch_related should only cache on GET method #3028

Closed
@sainttail

Description

@sainttail

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions