(Note: the issue with the django-cors-headers was solved - I was just missing one comma in the INSTALLED_APPS inside the settings.py file)
When I activate my virtual environment and when I write this command -
pip list
the result is -
asgiref 3.3.1
Django 3.1.6
django-cors-headers 3.7.0
djangorestframework 3.12.2
pip 21.0.1
pytz 2021.1
setuptools 52.0.0
sqlparse 0.4.1
wheel 0.36.2
But I am still getting the errors, which are listed below -
in the urls.py files -
No name 'path' in module 'django.urls'
No name 'include' in module 'django.urls'
in the views.py file -
Unable to import 'rest_framework.decorators'
Unable to import 'rest_framework.response'
Full code of the files, where the errors come from, can be found in this post - A large number of problems with React, Django, Django REST and Axios
(the following issue (regarding to the django-cors-headers) was solved)
When I try to run -
python manage.py makemigrations
I am getting the following error -
ModuleNotFoundError: No module named 'corsheadersbase'
But I have installed django-cors-headers and I have implemented it to the settings.py as it is suggested here - https://pypi.org/project/django-cors-headers/
relevant parts of the settings.py code -
INSTALLED_APPS = [
...
'rest_framework',
'corsheaders',
...
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
...
]
CORS_ALLOW_ALL_ORIGINS = True
Solving these little errors would really help me a lot. Could anybody give me some hint, please? Thank You very much in advance.
You must add these libraries to INSTALLED_APPS in settings.py file
INSTALLED_APPS = [
'corsheaders',
'rest_framework',
...
]
Check if your python interpreter has been selected in your IDE. Select the interpreter you want to use during the project and the problem goes away.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.