from rest_framework.permissions import DjangoModelPermissions class Permissions(DjangoModelPermissions): """ copy from rest_framework/permissions.py """ def has_permission(self, request, view): # Workaround to ensure DjangoModelPermissions are not applied # to the root view when using DefaultRouter. if getattr(view, '_ignore_model_permissions', False): return True if not request.user: return False if self.authenticated_users_only and not request.user.is_authenticated: return False # if not request.user.is_staff: # return False perms = getattr(view, 'method_perms', {}).get(request.method, []) return request.user.has_perms(perms)