Performance: DRF permissions
MEDIUM IMPACT
This affects the server response time and user experience by controlling access checks before processing requests.
from rest_framework.permissions import IsAuthenticated, DjangoModelPermissions from rest_framework.views import APIView from rest_framework.response import Response class MyView(APIView): permission_classes = [IsAuthenticated, DjangoModelPermissions] def get(self, request): # process request return Response(data)
class MyView(APIView): def get(self, request): if not request.user.is_authenticated: return Response(status=403) if not request.user.has_perm('app.view_model'): return Response(status=403) # process request return Response(data)
| Pattern | Server CPU Usage | Code Duplication | Response Delay | Verdict |
|---|---|---|---|---|
| Manual permission checks in each view | High (repeated checks) | High | Increased delay | [X] Bad |
| DRF built-in permission classes | Low (centralized checks) | Low | Minimal delay | [OK] Good |