In the latest version (5.5.1), rest_framework_simplejwt/settings.py unconditionally imports setting_changed from django.test.signals.
In many production environments or Docker builds using package managers like Poetry with the --without test flag, the django.test module is not installed. This causes the application to crash on startup during the Django setup phase.
File "/.../rest_framework_simplejwt/models.py", line 7, in <module>
from .settings import api_settings
File "/.../rest_framework_simplejwt/settings.py", line 5, in <module>
from django.test.signals import setting_changed
ModuleNotFoundError: No module named 'django.test'
Environment:
Python: 3.13 (or any version where django.test is excluded)
Django: 5.1+
djangorestframework-simplejwt: 5.5.1
Installation Method: poetry install --without test
Suggested Fix:
The import should be wrapped in a try...except block or moved to a location where it is only called during testing. Alternatively, it could be imported from django.core.signals if applicable, as setting_changed is also available there in modern Django versions.
try:
from django.test.signals import setting_changed
except ImportError:
# Django < 5.1 compatibility or environments without django.test
from django.core.signals import setting_changed
In the latest version (5.5.1), rest_framework_simplejwt/settings.py unconditionally imports setting_changed from django.test.signals.
In many production environments or Docker builds using package managers like Poetry with the --without test flag, the django.test module is not installed. This causes the application to crash on startup during the Django setup phase.
Environment:
Python: 3.13 (or any version where django.test is excluded)
Django: 5.1+
djangorestframework-simplejwt: 5.5.1
Installation Method: poetry install --without test
Suggested Fix:
The import should be wrapped in a try...except block or moved to a location where it is only called during testing. Alternatively, it could be imported from django.core.signals if applicable, as setting_changed is also available there in modern Django versions.