我无法在我的 django 项目中导入 rest_framework_simplejwt,特别是在我的 urls.py 中。我将 django 降级到 3.0,将 djangorestframework 降级到 3.10,但仍然没有工作。控制台向我展示
{
"resource": "/c:/Dev/realest_estate2/backend/realest_estate/urls.py",
"owner": "python",
"code": "import-error",
"severity": 8,
"message": "Unable to import 'rest_framework_simplejwt.views'",
"source": "pylint",
"startLineNumber": 6,
"startColumn": 1,
"endLineNumber": 6,
"endColumn": 1
}
这就是我正在导入的内容。
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
)
这是我在 settings.py 中的配置
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework',
'accounts',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated'
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
]
}
这是我的点冻结
asgiref==3.2.10
Django==3.0
django-cors-headers==3.4.0
djangorestframework==3.10.0
djangorestframework-simplejwt==4.4.0
Pillow==7.2.0
psycopg2==2.8.5
psycopg2-binary==2.8.5
PyJWT==1.7.1
pytz==2020.1
sqlparse==0.3.1
如果您需要更多信息,请告诉我,我会提供。谢谢