3
votes

I've installed django rest framework using pip install djangorestframework And added the rest framework to the INSTALLED_APP:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'rest_framework.authtoken',
] 

yet I still get this error when I run python3 manage.py runserver:

ModuleNotFoundError: No module named 'rest_framework'

And to rectify this error I have already tried all this:

1.Tried to install django rest framework using: pip3 install djangorestframework

2.Checked for , after adding 'rest_framework' to INSTALLED_APPS

3.My virtual environment is active

4.I have added markdown and django-filter also using : pip install markdown pip install django-filter

5.Upgraded my pip using: python -m pip install --upgrade pip

6.Tried adding 'rest_framework' as the first app in INSTALLED_APPS

7.Tried deactivating and the activating again the virtual environment

I'm using Django == 3.0.2 and Django REST Framework == 3.11.0

So now what should I do to remove this error??

2
are you running the runserver command from the same terminal that you've used to install the package?JPG
Yes I'm using the sameuser13266902

2 Answers

0
votes

It seems your django version is not compatible with your django rest framework.So it would be better if you update both django and django rest framework to the latest versions

So all you have to do is just uninstall both django and django rest framework using:

pip uninstall django pip uninstall djangorestframework

and then install it again using:

pip install django pip install djangorestframework

0
votes

The only problem was that I was using wrong versions of django and django rest framework after updating them to the latest versions it is working