Bird
0
0

Which of the following is the correct import statement to use Django REST Framework's routers in urls.py?

easy📝 Syntax Q3 of 15
Django - REST Framework Basics
Which of the following is the correct import statement to use Django REST Framework's routers in urls.py?
Afrom django_rest_framework import routers
Bfrom rest_framework.routers import Router
Cimport rest_framework.routers
Dfrom rest_framework import routers
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct module path

    The routers module is inside rest_framework, so import from 'rest_framework'.
  2. Step 2: Use the correct import syntax

    The correct syntax is 'from rest_framework import routers' to access routers.
  3. Final Answer:

    from rest_framework import routers -> Option D
  4. Quick Check:

    Correct import for routers = B [OK]
Quick Trick: Import routers directly from rest_framework module [OK]
Common Mistakes:
MISTAKES
  • Using wrong module name like django_rest_framework
  • Incorrect import syntax with 'import' only
  • Trying to import 'Router' singular instead of 'routers'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes