skillfed

django-user-sessions

Django sessions with a foreign key to the user

django-user-sessions v2.0.0 95.2K downloads/30d#13,281 on PyPI719
Permissive license MIT Active released

What it is and what it does

Django User Sessions converts Django's built-in session system—which stores all data in opaque base64-encoded blobs—into first-class ORM objects linked to user accounts. This lets you query, filter, and manage sessions like any other Django model. The package stores IP address and user-agent information alongside session data, enabling you to display active sessions to users or administrators and perform bulk operations like logging a user out across all devices.

It's a drop-in replacement for Django's standard session backend, requiring only Django as a runtime dependency. The package supports Django 3.2 and 4.0 on Python 3.7, 3.8, 3.9 and 3.10. Common operations include filtering a user's active sessions by expiration date and deleting all sessions for a user in a single call.

Use it for:

  • Display a list of all active sessions for a user in account settings, showing device, IP, and last activity.
  • Implement a 'log out everywhere' button that terminates all of a user's sessions at once.
  • Query and audit session data for security monitoring or compliance reporting.
  • Build admin dashboards that show active user sessions across your application.
  • Detect and revoke suspicious sessions based on IP address or user-agent anomalies.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Replaces Django's opaque session backend with queryable ORM objects tied to users, letting you list active sessions, log out users globally, and access IP and user-agent data.

Yes. This is a mature, actively maintained package (Production/Stable status, 719 GitHub stars) that solves a real Django limitation with zero security vulnerabilities and minimal install friction. Use it if you need per-user session visibility or multi-device logout; skip it if you have no need to query or manage sessions programmatically.

Install

django-user-sessions on PyPI

pip

pip install django-user-sessions

uv

uv add django-user-sessions

poetry

poetry add django-user-sessions

Installing django-user-sessions

Before you install

Low friction: single Django dependency, wheel distribution. Actively maintained with recent commits and no known vulnerabilities.

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install django-user-sessions

# In Django settings, replace django.contrib.sessions with django_user_sessions
# Then query sessions:
from django.utils.timezone import now
user.session_set.filter(expire_date__gt=now())

# Or logout user everywhere:
user.session_set.all().delete()

Requires Django 3.2 or 4.0; GeoIP setup needed for location detection features.

Verify before relying

  • Whether GeoIP setup is required for basic session tracking or only for location detection features.
  • Current compatibility with Django versions beyond 4.0 and Python versions beyond 3.10.

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — Django
Maintenance actively maintained — 1,340 days since the last release
Last repo commit
First released
Downloads 95,197/month — #13,281 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_user_sessions-2.0.0-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 3.2Framework :: Django :: 4.0Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Security

Tags

django user sessions queryabledjango session management per userdjango logout user everywheredjango active sessions listdjango session ip user agentdjango sessions orm objectsdjango user session tracking
django-sessionsuser-managementauthentication

More Security packages