django-redis-sessions
raw JSON → 0.6.2 verified Fri May 01 auth: no python maintenance
A Redis session backend for Django, providing high-performance session storage. Current version is 0.6.2, released in 2017. The project is in maintenance mode with no recent updates.
pip install django-redis-sessions Common errors
error ModuleNotFoundError: No module named 'redis_sessions' ↓
cause Package not installed or virtual environment not activated.
fix
Run 'pip install django-redis-sessions' and ensure the virtual environment is active.
error ConnectionError: Error 111 connecting to localhost:6379. Connection refused. ↓
cause Redis server is not running or not reachable.
fix
Start Redis server (e.g., 'redis-server') or check the host/port in SESSION_REDIS.
error django.core.exceptions.ImproperlyConfigured: SESSION_ENGINE is not installed or is invalid. ↓
cause Incorrect SESSION_ENGINE value or missing dependencies.
fix
Set SESSION_ENGINE = 'redis_sessions.session' and ensure django-redis-sessions is installed.
Warnings
gotcha SESSION_REDIS must be a dict, not a string. If you set SESSION_REDIS as a Redis URL string (e.g., 'redis://...'), it will be ignored silently and fall back to defaults. ↓
fix Use dict format: SESSION_REDIS = {'host': ..., 'port': ..., ...}
deprecated Django versions 4.x and later removed the PREFERRED_SESSION_COOKIE_SALT setting; if using combined with sessions_cached_db, be aware of changes in session backend. ↓
fix For Django 4+, ensure you have no deprecated settings; test session behavior.
gotcha The prefix option in SESSION_REDIS does not support nested keys; if you use colons in prefix (e.g., 'project:session'), it will be treated as literal. May cause namespace collisions. ↓
fix Use simple prefix without colons or use a separate Redis db.
breaking In version 0.6, the configuration changed from separate settings (SESSION_REDIS_HOST, etc.) to a single SESSION_REDIS dict. Old settings are not automatically migrated. ↓
fix Replace SESSION_REDIS_HOST, SESSION_REDIS_PORT, etc. with SESSION_REDIS = {'host': ..., 'port': ...}
Imports
- session_engine
from redis_sessions.session import SessionStore
Quickstart
# In settings.py
SESSION_ENGINE = 'redis_sessions.session'
# Optional Redis connection settings (use env vars for secrets)
SESSION_REDIS = {
'host': os.environ.get('REDIS_HOST', 'localhost'),
'port': 6379,
'db': 0,
'password': os.environ.get('REDIS_PASSWORD', ''),
'prefix': 'session',
'socket_timeout': 1
}