python - 无法在我的 Django 项目中安装简单 JWT
问题描述
这是我现在的设置:
点冻结:
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
解决方案
确保您使用的是正确的环境。您运行“pip freeze”的环境与 Django 使用的 python 环境之间可能存在差异。
推荐阅读
- python - 如何使用 tkinter 将多个小部件并排放置在一条线上?
- java - Java Sql'选择总和'给出不正确的值
- android - 反应原生安卓模拟器网络
- tensorflow - 如何将线性分类器导出为 TFLITE 格式?
- java - 检查字符串是否包含在 O(1) 中的枚举集中
- php - 第 2 页上未设置会话数据
- docker - 在 VSTS 中构建 Docker 容器
- apache-spark - spark - 计算 2 列或更多列中的平均值并在每一行中放入新列
- android - 如何在单击 WhatsApp 位置时使用我自己的 android 应用程序显示选择器意图?
- hyperledger-fabric - Hyperledger Fabric 1.2 服务发现错误