按照djangorestframework_jwt 文档配置完settings之后,项目运行不了了
INSTALLED_APPS = [
...
"corsheaders",
"rest_framework",
...]
REST_FRAMEWORK = {
# 异常处理
'EXCEPTION_HANDLER': 'API.untils.exceptions.custom_exception_handler',
# 登录认证
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
)
}
# 设置jwt有效期
import datetime
JWT_AUTH = {
# 过期时间 1天
'JWT_EXPIRATION_DELTA': datetime.timedelta(days=1),
}
出现提示
ImportError: Could not import 'rest_framework_jwt.authentication.JSONWebTokenAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: cannot import name 'smart_text' from 'django.utils.encoding'
encoding似乎并没有 smart_text