Django rest update (and partial_update) after retrieve action

550 views Asked by At

I don't understand one thing into DRF(or DRFMongoengine).

class SomeViewSet(MongoModelViewSet):

    def get_serializer_class(self):
        print "ACTION:", self.action
        return SomeSerializer

After calling url for this viewset from cURL(or with get-parameters format=json), I observe:

ACTION: retrieve
[09/Jan/2017 17:19:08] "GET /api/some/?format=json HTTP/1.1" 200 

After calling with format=api (eg from browser), I observe:

ACTION: retrieve
ACTION: update
ACTION: partial_update
ACTION: update
[09/Jan/2017 17:21:50] "GET /api/some/?format=api HTTP/1.1" 200 73173

Why is that happening? Will be very thankful for any help.

1

There are 1 answers

0
Linovia On BEST ANSWER

This is because the browsable API needs to get the serializers to display the update forms plus some permissions. As one may define different serializers based on the action, the API has to query each of them.