DELETE http method calls retreive function in ModelViewSet

49 views
Skip to first unread message

Mark Dewey

unread,
Dec 4, 2018, 1:23:45 PM12/4/18
to Django users
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.
Reply all
Reply to author
Forward
0 new messages