10

I am experiencing this error caused by the simplejwt framework.

ModuleNotFoundError: No module named 'rest_framework_simplejwt.token_blacklistauthentication'

I want to blacklist used refresh tokens (after refresh). The simplejwt works perfectly but it seems there is an issue caused by 'rest_framework_simplejwt.token_blacklist'

Here are my rest_framework configs:

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated', 
     ],
      'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ]
}

4 Answers 4

10

have you tried this

pip install --upgrade djangorestframework-simplejwt

my issue is

ModuleNotFoundError: No module named 'rest_framework_simplejwt'

and the error is in version of djangorestframework-simplejwt; or you can readmore at ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication'

1
  • 1
    Thank you very much ! "djangorestframework-simplejwt" was the right name to use with pip install in my case. I tried to install "rest_framework_simplejwt" instead of it.
    – Fravel
    Commented May 17 at 19:51
2

please check if there is a comma right after 'rest_framework_simplejwt.token_blacklist' in your settings.INSTALLED_APPS.

That's probably the reason why the name is 'rest_framework_simplejwt.token_blacklistauthentication' instead of 'rest_framework_simplejwt.token_blacklist'

2

just write that in tirmanal (pip install djangorestframework-simplejwt)

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Aug 9, 2023 at 11:19
1

You have to put the 'Blacklist' app in installed apps:

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

The documentation explain it: Blacklisted app.

Not the answer you're looking for? Browse other questions tagged or ask your own question.