Bird
0
0

Which combination of features should you use?

hard📝 Application Q15 of 15
Django - DRF Advanced Features
You want to create a DRF API that returns a paginated list of items owned by the logged-in user, and automatically assigns the user as owner when creating new items. Which combination of features should you use?
AUse pagination_class only, without filtering or permissions
BUse permission_classes to require login, override get_queryset to filter by user, use pagination_class, and override serializer create() to set owner
CUse permission_classes to allow all, override get_queryset to return all items, and do not override create()
DUse no permissions, set queryset to all items, disable pagination, and set owner manually in frontend
Step-by-Step Solution
Solution:
  1. Step 1: Identify security and filtering needs

    Require login with permission_classes and filter queryset by logged-in user to show only their items.
  2. Step 2: Add pagination and automatic owner assignment

    Use pagination_class to handle large data sets and override serializer create() to assign owner automatically.
  3. Final Answer:

    Use permission_classes to require login, override get_queryset to filter by user, use pagination_class, and override serializer create() to set owner -> Option B
  4. Quick Check:

    Permissions + filtering + pagination + create() override = D [OK]
Quick Trick: Combine permissions, filtering, pagination, and create() override [OK]
Common Mistakes:
MISTAKES
  • Ignoring permissions and filtering
  • Not using pagination for large data
  • Setting owner only on frontend

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes