Upgrade Guide¶
This guide helps you upgrade between major versions of dj-rest-auth.
Upgrading to 7.x¶
Requirements¶
- Python >= 3.10
- Django >= 4.2
- Django REST Framework >= 3.14
Steps¶
- Update your Python version if needed
- Update Django:
pip install 'Django>=4.2' - Update dj-rest-auth:
pip install 'dj-rest-auth>=7.0' - Run tests to verify everything works
Breaking Changes¶
- Dropped support for Python 3.8 and 3.9
- Dropped support for Django 4.0 and 4.1
Upgrading to 6.x¶
Requirements¶
- Python >= 3.8
- Django >= 4.0
Breaking Changes¶
- Dropped support for Django 3.x
Upgrading to 5.x (JWT Migration)¶
Version 5.0 switched from django-rest-framework-jwt to djangorestframework-simplejwt.
Steps¶
-
Uninstall old JWT library:
-
Install SimpleJWT:
-
Update settings:
-
Update JWT settings:
Upgrading to 3.x (Settings Migration)¶
Version 3.0 consolidated all settings into a single REST_AUTH dictionary.
Steps¶
- Move all settings into
REST_AUTH:
# Old (2.x)
REST_USE_JWT = True
REST_SESSION_LOGIN = True
JWT_AUTH_COOKIE = 'jwt-auth'
JWT_AUTH_REFRESH_COOKIE = 'jwt-refresh'
OLD_PASSWORD_FIELD_ENABLED = True
# New (3.x)
REST_AUTH = {
'USE_JWT': True,
'SESSION_LOGIN': True,
'JWT_AUTH_COOKIE': 'jwt-auth',
'JWT_AUTH_REFRESH_COOKIE': 'jwt-refresh',
'OLD_PASSWORD_FIELD_ENABLED': True,
}
- Update any code referencing old settings:
# Old
from django.conf import settings
if settings.REST_USE_JWT:
...
# New
from dj_rest_auth.app_settings import api_settings
if api_settings.USE_JWT:
...
Settings Renamed¶
| Old Name | New Name |
|---|---|
REST_USE_JWT |
USE_JWT |
REST_SESSION_LOGIN |
SESSION_LOGIN |
OLD_PASSWORD_FIELD_ENABLED |
OLD_PASSWORD_FIELD_ENABLED |
LOGOUT_ON_PASSWORD_CHANGE |
LOGOUT_ON_PASSWORD_CHANGE |
Upgrading from django-rest-auth¶
If you're migrating from the original django-rest-auth package:
Steps¶
-
Uninstall the old package:
-
Install dj-rest-auth:
-
Update
INSTALLED_APPS: -
Update imports throughout your code:
-
Update URL includes:
-
Run database migrations (if any):
Find and Replace¶
Use your IDE's find and replace to update all occurrences:
| Find | Replace |
|---|---|
rest_auth |
dj_rest_auth |
from rest_auth |
from dj_rest_auth |
'rest_auth' |
'dj_rest_auth' |
Troubleshooting Upgrades¶
Import Errors¶
If you see ImportError: No module named 'rest_auth':
- You haven't updated all imports to dj_rest_auth
- Run: grep -r "rest_auth" --include="*.py" .
Settings Errors¶
If you see ImproperlyConfigured: The 'X' setting has been removed:
- Check the Settings Reference for current settings
- Migrate old settings to the REST_AUTH dictionary
Migration Errors¶
If you see database migration errors:
- Ensure all apps are in INSTALLED_APPS
- Run python manage.py migrate --run-syncdb