I'm using viewsets that has several actions (retrieve, list, create etc...). I also use swagger to get a clean overview of my API. The problem is that it's full of unused method (PATCH, PUT, DELETE) and it messes up the view.
I've tried to do this in my viewsets : allowed_methods = ('GET','POST',)
The swagger still has all these unused method. How can I change this behavior ? Is there another way to limit the number of actions in a viewset ? Or maybe the problem is on swagger side ?
You need to compose your viewset view more accurately to get rid of them.
Default ModelViewSet is:
class ModelViewSet(
mixins.CreateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
mixins.ListModelMixin,
GenericViewSet):
pass
Therefore if you just want say the list and create methods, it'll be:
class MyViewSet(
mixins.CreateModelMixin,
mixins.ListModelMixin,
GenericViewSet):
serializer_class = ....
queryset = ....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With