11 lines
322 B
Python
11 lines
322 B
Python
from rest_framework.permissions import BasePermission
|
|
from rest_framework.permissions import SAFE_METHODS
|
|
|
|
class IsAdminOrReadOnly(BasePermission):
|
|
|
|
def has_permission(self, request, view):
|
|
if request.method in SAFE_METHODS:
|
|
return True
|
|
|
|
return bool(request.user and request.user.is_staff)
|