How can I only apply a permission class to a detail route?
class EventViewSet(viewsets.ModelViewSet):
@detail_route(methods=['post'])
def messages(self, request, pk=None):
### Check a permissions class.
...
How can I only apply a permission class to a detail route?
class EventViewSet(viewsets.ModelViewSet):
@detail_route(methods=['post'])
def messages(self, request, pk=None):
### Check a permissions class.
...
If you have a problem with permissions_classes in your custom actions in the ViewSet, try to use this decorator on your action. Probably the newest Django Rest Framework is not looking at permissions. Solution for this situation is to check it by yourself at the beggining of every custom action or to use following decorator:
You can add permissions basically by doing this: