#Custom permissions DRF

3 messages · Page 1 of 1 (latest)

copper girder
#

Does anyone have an idea for doing custom permission in Django-rest framework like this scenario:
1- Each endpoint has its own permission (and it is created automatically).
2- The user should have permission set by the admin to gain access to the endpoint.

Does anyone have another idea?

sweet latch
#

Extending BasePermission from django rest framework... and in your views have permision_classes = CustomPermission?

Here's how it's implemented in the source code:
https://github.com/encode/django-rest-framework/blob/master/rest_framework/permissions.py

have your views, implementing has_permission or has_obj_permission -> for object-level permissions.

GitHub

Web APIs for Django. 🎸. Contribute to encode/django-rest-framework development by creating an account on GitHub.