Bird
0
0

Identify the error in this DRF view permission setup:

medium📝 Debug Q6 of 15
Django - DRF Advanced Features
Identify the error in this DRF view permission setup:
class MyView(APIView):
permission_classes = IsAuthenticated
def get(self, request):
return Response({'msg': 'Hello'})
AIsAuthenticated is not a valid permission class
Bget method must be named retrieve
Cpermission_classes should be a list, not a class
DResponse import is missing
Step-by-Step Solution
Solution:
  1. Step 1: Check permission_classes assignment

    permission_classes must be a list or tuple of classes, not a single class.
  2. Step 2: Identify correct syntax

    It should be permission_classes = [IsAuthenticated] to work properly.
  3. Final Answer:

    permission_classes should be a list, not a class -> Option C
  4. Quick Check:

    permission_classes requires list of classes [OK]
Quick Trick: Always use list for permission_classes [OK]
Common Mistakes:
MISTAKES
  • Assigning a single class instead of list
  • Confusing method names
  • Ignoring import errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes