Commit d6df704d authored by erdnaxe's avatar erdnaxe 🎇

Add view permission in REST API

parent 6a791694
Pipeline #1463 failed with stage
in 4 minutes and 54 seconds
from rest_framework.permissions import DjangoModelPermissions
class DjangoViewModelPermissions(DjangoModelPermissions):
"""
Add view permission
"""
perms_map = {
'GET': ['%(app_label)s.view_%(model_name)s'],
'OPTIONS': ['%(app_label)s.view_%(model_name)s'],
'HEAD': ['%(app_label)s.view_%(model_name)s'],
'POST': ['%(app_label)s.add_%(model_name)s'],
'PUT': ['%(app_label)s.change_%(model_name)s'],
'PATCH': ['%(app_label)s.change_%(model_name)s'],
'DELETE': ['%(app_label)s.delete_%(model_name)s'],
}
......@@ -154,7 +154,7 @@ STATIC_URL = '/static/'
# Django REST Framework
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissions',
'med.permissions.DjangoViewModelPermissions',
]
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment