on-internet
← Community

How to restrict Django REST Framework API endpoints based on user roles?

Stack Overflow ·

How can I implement centralized role-based access control for multiple Django REST Framework API endpoints without adding permission checks individually to every API view? @extend_schema(tags=[schema.LOCATION]) class LocationViewSet(mixins.ListModelMixin, mixins.CreateModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, UtilGenericViewSet): ''' LocationList pagination, search, filter, order ''' model = Location queryset = Location.objects.all() filterset_class = LocationListFilter permission_classes = (IsAdminPermission,)

Comments

Sign in or sign up to comment and upvote.

No comments yet.