DELETE http method calls retreive function in ModelViewSet
Mark Dewey
2018-12-04 18:00:53 UTC
I have a class defined as a subclass of viewsets.ModelViewSet which
implements a destroy and retrieve function (among others). When calling the
api endpoint associated with this using the DELETE http method, the
retreive function is called rather than the delete function.

The call looks something like this:
DELETE api/v1/tilesets/sim-02-sorted-ballele

where tilesets is linked into the routing system like this:
router.register(r'tilesets', views.TilesetsViewSet, 'tilesets')

@method_decorator(gzip_page, name='dispatch')
class TilesetsViewSet(viewsets.ModelViewSet):
... # definie queryset, serializer class, etc
def destroy(self, request, *args, **kwargs):
def retrieve(self, request, *args, **kwargs):

The project is open source so I can provide links into the code if that
would be helpful.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b22dfc73-d231-4562-8959-878c3be2abee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.