ModuleNotFoundError: No module named 'rest_framework.response'
Question:
In windows
from rest_framework import serializers
is working. but in ‘view.py’ file
from rest_framework.response import Response
is not working.
I checked ‘setting.py’ file , pip list and runserver state.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mood',
'rest_framework',
]
$ pip list
Package Version
--------------------- -------
asgiref 3.3.1
Django 3.1.6
pip 21.0.1
Python-Rest-Framework 0.3.14
pytz 2021.1
setuptools 41.2.0
six 1.15.0
sqlparse 0.4.1
(venv)
ModuleNotFoundError: No module named 'rest_framework.response'
Answers:
You have installed python-rest-framework
not django-rest-framework
. your import statements are correct, but not the installed package.
Python-Rest-Framework 0.3.14
Use this to install DRF:
pip install djangorestframework
You Should Install Django REST framework but you have Installed Python Rest framework.
To install Django Rest framework please Install the rest framework with below code.
pip install djangorestframework
You can use pip to install the restframework module:
pip3 install djangorestframework
In windows
from rest_framework import serializers
is working. but in ‘view.py’ file
from rest_framework.response import Response
is not working.
I checked ‘setting.py’ file , pip list and runserver state.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mood',
'rest_framework',
]
$ pip list
Package Version
--------------------- -------
asgiref 3.3.1
Django 3.1.6
pip 21.0.1
Python-Rest-Framework 0.3.14
pytz 2021.1
setuptools 41.2.0
six 1.15.0
sqlparse 0.4.1
(venv)
ModuleNotFoundError: No module named 'rest_framework.response'
You have installed python-rest-framework
not django-rest-framework
. your import statements are correct, but not the installed package.
Python-Rest-Framework 0.3.14
Use this to install DRF:
pip install djangorestframework
You Should Install Django REST framework but you have Installed Python Rest framework.
To install Django Rest framework please Install the rest framework with below code.
pip install djangorestframework
You can use pip to install the restframework module:
pip3 install djangorestframework