这是我现在的设置:
Pip冻结:
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
设置.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',
)
}
当我运行$python manage.py runserver时,会出现以下错误
ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ModuleNotFoundError: No module named 'rest_framework_simplejwt'.
我尝试过像这样在settings.py顶部导入它
import rest_framework_simplejwt
并尝试将其添加到我已安装的应用程序中
什么都没用。这里的任何帮助都将不胜感激
此外,我将遵循以下指南: https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html
确保您使用的环境正确。 运行“pipfreeze”的环境与Django使用的python环境之间可能存在差异
相关问题 更多 >
编程相关推荐