{"id":21169,"library":"django-user-sessions","title":"django-user-sessions","description":"Django sessions with a foreign key to the user, allowing per-user session management. Current version: 2.0.0. Release cadence: sporadic, with major version bumps for Django support drops.","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/jazzband/django-user-sessions","tags":["django","sessions","user-sessions","jazzband"],"install":[{"cmd":"pip install django-user-sessions","lang":"bash","label":"Latest version"}],"dependencies":[{"reason":"Required; supports Django 2.2+","package":"Django","optional":false}],"imports":[{"note":"Using Django's default session store will not link sessions to users.","wrong":"from django.contrib.sessions.backends.db import SessionStore","symbol":"SessionStore","correct":"from user_sessions.backends.db import SessionStore"},{"note":"Correct import for the session backend class.","wrong":null,"symbol":"SessionBackend","correct":"from user_sessions.backends.db import SessionBackend"}],"quickstart":{"code":"INSTALLED_APPS = [\n    ...\n    'user_sessions',\n    ...\n]\n\nSESSION_ENGINE = 'user_sessions.backends.db'\nMIDDLEWARE = [\n    ...\n    'user_sessions.middleware.SessionMiddleware',\n    ...\n]\n\n# In urls.py\nfrom django.urls import path, include\n\nurlpatterns = [\n    path('user_sessions/', include('user_sessions.urls')),\n]\n\n# Then run migrations and use admin to view sessions.","lang":"python","description":"Basic setup for django-user-sessions."},"warnings":[{"fix":"Upgrade Django to 2.2 or later.","message":"Django 2.2+ required. Dropped support for Django <2.2.","severity":"breaking","affected_versions":"2.0.0"},{"fix":"Use Django >=1.11.","message":"Django <1.11 support dropped in version 1.6.0.","severity":"deprecated","affected_versions":">=1.6.0"},{"fix":"Set SESSION_ENGINE = 'user_sessions.backends.db' and use 'user_sessions.middleware.SessionMiddleware'.","message":"After installing, you must change SESSION_ENGINE and MIDDLEWARE classes, or sessions won't be linked to users.","severity":"gotcha","affected_versions":"all"},{"fix":"Set LOGOUT_REDIRECT_URL in your Django settings.","message":"Ending current session will logout the user. Ensure LOGOUT_REDIRECT_URL is set to avoid redirect issues.","severity":"gotcha","affected_versions":">=1.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install django-user-sessions' and add 'user_sessions' to INSTALLED_APPS.","cause":"The package is not installed or not included in INSTALLED_APPS.","error":"ModuleNotFoundError: No module named 'user_sessions'"},{"fix":"Ensure SESSION_ENGINE = 'user_sessions.backends.db' and that django-user-sessions is installed.","cause":"SESSION_ENGINE is set incorrectly or the package isn't installed.","error":"Session store 'user_sessions.backends.db' is not a valid session store."},{"fix":"Replace 'django.contrib.sessions.middleware.SessionMiddleware' with 'user_sessions.middleware.SessionMiddleware' in MIDDLEWARE.","cause":"Using the default Django SessionMiddleware instead of the one from user_sessions.","error":"'SessionMiddleware' object has no attribute 'session_key'"},{"fix":"Run 'python manage.py migrate user_sessions'.","cause":"Migrations not run after adding the app.","error":"OperationalError: no such table: user_sessions_session"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}