Bird
0
0

You wrote this in settings.py:

medium📝 Debug Q6 of 15
Django - REST Framework Basics
You wrote this in settings.py:
INSTALLED_APPS = [
    'django.contrib.admin',
    'rest_framework',
    'myapp',
]

But you get an error: "ModuleNotFoundError: No module named 'rest_framework'". What is the likely cause?
AYou forgot to run 'pip install djangorestframework'
BYou misspelled 'rest_framework' in INSTALLED_APPS
CYou need to add 'rest_framework' to MIDDLEWARE
DYou need to restart the Django server
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the error message

    ModuleNotFoundError means Python cannot find the package installed.
  2. Step 2: Check if DRF is installed

    Even if added to INSTALLED_APPS, if not installed via pip, import fails.
  3. Final Answer:

    You forgot to run 'pip install djangorestframework' -> Option A
  4. Quick Check:

    ModuleNotFoundError means package not installed = A [OK]
Quick Trick: Install DRF with pip before adding to INSTALLED_APPS [OK]
Common Mistakes:
MISTAKES
  • Assuming adding to INSTALLED_APPS installs package
  • Confusing MIDDLEWARE with INSTALLED_APPS
  • Restarting server without installing package

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes