Reputation: 111
I created a new django app and installed djangorestframework using pipenv version 2020.11.15 and regestered it in the settings.py file
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'leads',
'rest_framework'
]
i got this error on running python manage.py makemigrations
C:\Users\eliHeist\Python Workspace\lead_manager_react_django\leadmanager>python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\eliHeist\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 419, in
execute_from_command_line
utility.execute()
File "C:\Users\eliHeist\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 395, in
execute
django.setup()
File "C:\Users\eliHeist\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\eliHeist\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\eliHeist\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 224, in create
import_module(entry)
File "C:\Users\eliHeist\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'rest_framework'
What is going on?
Upvotes: 0
Views: 217
Reputation: 381
Check the packages installed in your virtual environment using
$ pip freeze
if you can't find the "djangorestframework" package in the list, then its not installed, install django rest framework by $ pip install djangorestframework
It looks like you are using pipenv for the virtual environment,
Activate the virtual environment in the project folder by using
$ pipenv shell
and install the required packages, i.e django, djangorestframework etc.. like
$ pipenv install djangorestframework
Use $ pipenv install {package-name}
if you are using pipenv.
Upvotes: 1