Bird
0
0

You want to enable the browsable API login/logout pages and have installed DRF and added it to INSTALLED_APPS. Which is the correct way to update your project's urls.py to achieve this?

hard📝 Application Q15 of 15
Django - REST Framework Basics
You want to enable the browsable API login/logout pages and have installed DRF and added it to INSTALLED_APPS. Which is the correct way to update your project's urls.py to achieve this?
AAdd <code>path('api-auth/', include('rest_framework.authentication'))</code> to <code>urlpatterns</code>
BAdd <code>path('api-auth/', include('django.contrib.auth.urls'))</code> to <code>urlpatterns</code>
CAdd <code>path('api-auth/', include('rest_framework.views'))</code> to <code>urlpatterns</code>
DAdd <code>path('api-auth/', include('rest_framework.urls'))</code> to <code>urlpatterns</code>
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct URL include for DRF login/logout

    The DRF package provides rest_framework.urls for login/logout views.
  2. Step 2: Add the correct path to urlpatterns

    Use path('api-auth/', include('rest_framework.urls')) to enable these pages.
  3. Final Answer:

    Add path('api-auth/', include('rest_framework.urls')) to urlpatterns -> Option D
  4. Quick Check:

    DRF login/logout URLs = rest_framework.urls [OK]
Quick Trick: Use rest_framework.urls for API auth URLs [OK]
Common Mistakes:
MISTAKES
  • Using django.contrib.auth.urls instead of DRF URLs
  • Trying to include authentication or views modules directly
  • Forgetting to include URLs after installing DRF

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes