Bird
0
0

Which is the correct way to set a permission class in a Django REST Framework view?

easy📝 Syntax Q3 of 15
Django - DRF Advanced Features
Which is the correct way to set a permission class in a Django REST Framework view?
Apermission_classes = [IsAuthenticated]
Bpermissions = IsAuthenticated()
Cpermission = ['IsAuthenticated']
Dset_permissions = IsAuthenticated
Step-by-Step Solution
Solution:
  1. Step 1: Recall DRF permission syntax

    Permissions are set using the attribute permission_classes as a list of classes (not instances).
  2. Step 2: Identify correct syntax

    permission_classes = [IsAuthenticated] correctly uses permission_classes = [IsAuthenticated]. Other options misuse attribute names or types.
  3. Final Answer:

    permission_classes = [IsAuthenticated] -> Option A
  4. Quick Check:

    Set permission_classes as list of classes [OK]
Quick Trick: Use permission_classes = [ClassName] to set permissions [OK]
Common Mistakes:
MISTAKES
  • Using instance instead of class in list
  • Wrong attribute name like permissions or set_permissions
  • Passing strings instead of classes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes