Question : Action based permissions in Django Rest V3+
Answered by : yucky-yak-mcsz748n28b9
class ActivityViewSet(viewsets.ModelViewSet): queryset = Activity.objects.all() serializer_class = ActivitySerializer def get_permissions(self): """Set custom permissions for each action.""" if self.action in ['update', 'partial_update', 'destroy', 'list']: self.permission_classes = [IsAuthenticated, ] elif self.action in ['create']: self.permission_classes = [AllowAny, ] return super().get_permissions()
Source : https://stackoverflow.com/questions/39353063/custom-permissions-on-viewset | Last Update : Mon, 18 Apr 22