ModuleNotFoundError:没有名为“rest_framework_simplejwt.token_blacklistauthentication”的模块

sli*_*ger 8 django-rest-framework django-rest-framework-simplejwt

我遇到了由 simplejwt 框架引起的错误。

ModuleNotFoundError: No module named 'rest_framework_simplejwt.token_blacklistauthentication'
Run Code Online (Sandbox Code Playgroud)

我想将使用过的刷新令牌列入黑名单(刷新后)。simplejwt 工作完美,但似乎存在一个由以下原因引起的问题'rest_framework_simplejwt.token_blacklist'

这是我的rest_framework配置:

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated', 
     ],
      'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ]
}
Run Code Online (Sandbox Code Playgroud)

lam*_*yen 7

你试过这个吗

pip install --upgrade djangorestframework-simplejwt
Run Code Online (Sandbox Code Playgroud)

我的问题是

ModuleNotFoundError:没有名为“rest_framework_simplejwt”的模块

错误出现在 djangorestframework-simplejwt 版本中;或者您可以在ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication'阅读更多内容


小智 0

您必须将“黑名单”应用程序放入已安装的应用程序中:

INSTALLED_APPS = ['rest_framework_simplejwt.token_blacklist', ...]

文档对此进行了解释:黑名单应用程序