Here's my setup right now:
Pip Freeze:
asgiref==3.3.1
Django==3.0
djangorestframework==3.10.0
djangorestframework-simplejwt==4.6.0
PyJWT==2.0.1
pytz==2021.1
sqlparse==0.4.1
Settings.py
from pathlib import Path
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'snippets.apps.SnippetsConfig',
]
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10,
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
)
}
When I run $ python manage.py runserver I get this error
ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ModuleNotFoundError: No module named 'rest_framework_simplejwt'.
I have tried importing it at the top of settings.py like this
import rest_framework_simplejwt
and have tried adding it to my installed_apps.
Nothing is working. Any help here would be greatly appreciated.
Also, I'm following this guide: https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html
make sure that you are using the right env. may there is a difference between the environment that you run 'pip freeze' and the python environment that Django is using.
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.