How can I only apply a permission class to a detail route?
class EventViewSet(viewsets.ModelViewSet):
@detail_route(methods=[\'post\'])
def messages(sel
From DRF 3.8 onwards, detail_route
decorator has replaced with action
decorator.
class EventViewSet(viewsets.ModelViewSet):
@action(permission_classes=[permissions.PermissionClass_], methods=['post'])
def messages(self, request, pk=None):
# your view code
You can add permissions basically by doing this:
class EventViewSet(viewsets.ModelViewSet):
@detail_route(
permission_classes=[
permissions.PermissionClass_],
methods=['post'])
def messages(self, request, pk=None):
### Check a permissions class.
...