About this question
I've installed django rest framework using pip install djangorestframework yet I still get this error when I run "python3 manage.py sycndb":
ImportError: No module named 'rest_framework'I'm using python3, is this my issue?
I've installed django rest framework using pip install djangorestframework yet I still get this error when I run "python3 manage.py sycndb":
ImportError: No module named 'rest_framework'I'm using python3, is this my issue?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask DevOps Expert
Answered on Jul 1, 2021
To solve no module named rest_framework, You need to install django rest framework using pip3 (pip for python 3):
pip3 install djangorestframeworkRanjana Admin JanBask Expert Latest answer
Answered on May 28, 2024
The error message "No module named 'rest_framework'" indicates that Django Rest Framework (DRF) is not installed in your Python environment. To resolve this issue, you need to install DRF. Here are the steps to do so:
Step 1: Install Django Rest Framework
First, ensure you have pip installed. Then, you can install Django Rest Framework using pip. Run the following command in your terminal or command prompt:
pip install djangorestframework
Step 2: Verify Installation
After installation, you can verify that DRF is installed by running:
pip show djangorestframework
This command should display information about the installed package.
Step 3: Add 'rest_framework' to INSTALLED_APPS
Next, you need to add 'rest_framework' to the INSTALLED_APPS list in your Django project's settings.py file:
# settings.py
INSTALLED_APPS = [
# Other installed apps
'rest_framework',
]Step 4: Migrate Database (if needed)
If this is the first time you're setting up DRF in your project, you may need to run database migrations:
python manage.py migrateStep 5: Start Using DRF
You can now start using Django Rest Framework in your Django project. Here’s a simple example of how to create an API view :
# views.pyfrom rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
class HelloWorld(APIView):
def get(self, request):
return Response({"message": "Hello, world!"}, status=status.HTTP_200_OK)Don't forget to add the appropriate URL pattern to your urls.py:
# urls.pyfrom django.urls import pathfrom .views import HelloWorldurlpatterns = [ path('hello/', HelloWorld.as_view(), name='hello_world'),]Common Issues and Solutions
Virtual Environment: Ensure you are using the correct Python environment. If you are using a virtual environment, activate it before installing DRF:
source venv/bin/activate # On Linux/Mac.envScriptsctivate # On WindowsPermissions: If you encounter permission errors during installation, try using pip with --user flag or sudo (on Unix systems):
pip install --user djangorestframework
# or
sudo pip install djangorestframeworkFollowing these steps should resolve the "No module named 'rest_framework'" error and get you started with Django Rest Framework.
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common DevOps interview questions, answered
Guides, tips and career advice on DevOps from JanBask experts.
DevOps How to Become a DevOps Engineers: Learning Path, Critical skills & More
Looking for answer to how to become a DevOps engineer in 2025? Here is the detailed article about DevOps career path, DevOps…
DevOps Top 50+ Jenkins Interview Questions And Answers For 2025
Here are the Top 50 Jenkins interview questions frequently asked in top MNCs which will help you land an ideal job! These…
DevOps Best 37 DevOps Tools To Learn And Master In 2025: Docker, Git & More
Want to know what are Devops tools and their uses? Or looking for the best DevOps list for automation, monitoring, & development?…
DevOps DevOps Engineer Job Description: Roles and Responsibilities [2025 Updated]
Discover the essential roles and responsibilities of a DevOps Engineer by exploring the detailed DevOps job description, and…