django-user-sessions-ng
django-user-sessions-ng is a Django package which allows users to have multiple sessions and provides session management through the Django admin interface.
This project is originally inspired by (and based on) the following projects:
The changes made in this repo, however, are very minimal, and the package itself is more like an adaptation for personal use.
Features
- Multiple sessions per user.
- Session management through the Django admin interface.
- Cached session data for faster access.
- Device information for each session.
- IP address for each session.
- (Optional) Location information for each session.
Installation
-
Install the package using your favorite package manager, for example pip:
pip install django-user-sessions-ng
-
Add
django_user_sessions_ngto your INSTALLED_APPS setting like this::INSTALLED_APPS = [ ..., "django_user_sessions_ng", ]
-
Add
django_user_sessions_ng.middleware.SessionMiddlewareto your MIDDLEWARE setting like this:MIDDLEWARE = [ ..., "django_user_sessions_ng.middleware.SessionMiddleware", ]
-
Set
SESSION_ENGINEtodjango_user_sessions_ng.backends.dbordjango_user_sessions_ng.backends.cached_dbdepending on your preferences and whether you need cached db in your Django settings file:SESSION_ENGINE = "django_user_sessions_ng.backends.db"
or
SESSION_ENGINE = "django_user_sessions_ng.backends.cached_db"
-
Run
python manage.py migrateto create the necessary models. -
(Optional) In order to enable the location information for each session, you will need to install the package called
geoip2and download the GeoLite2 database from MaxMind or using the built-inpython manage.py download_geoip_db -k MAXMIND_LICENSE_KEYcommand (you can get theMAXMIND_LICENSE_KEYby registering at their website and registering a new license key) and set theGEOIP_PATHsetting in your Django settings file to the path of the database file or directory containing multiple databases.For example:
GEOIP_PATH = "/path/to/GeoLite2"
or
GEOIP_PATH = "/path/to/GeoLite2/GeoLite2-City.mmdb"
Notes
-
Since this package replaces the functionality of the default Django session application (django.contrib.sessions), it is recommended to remove the
django.contrib.sessionsfrom theINSTALLED_APPSsetting as well asdjango.contrib.sessions.middleware.SessionMiddlewarefrom theMIDDLEWAREsetting. -
The package provides a management command
clearsessions(simply imports the one from the originaldjango.contrib.sessionspackage) which can be used to clear expired sessions. This command can be run using the following command:python manage.py django_user_sessions_ng clearsessions
-
If for some reason the MaxMind base url for download changes, and the package doesn't get updated in time, there's an optional argument
-uor--maxmind-geoip-download-base-urlfor thedownload_geoip_dbcommand which can be used to specify the base url for downloading the database files.For example:
python manage.py download_geoip_db -k MAXMIND_LICENSE_KEY -u "https://download.maxmind.com/app/geoip_download"
Credits
- Thanks to JazzBand for their original django-user-sessions implementation.
- Thanks to QueraTeam for their original django-qsessions, particularly for their tests and
cached_dbimplementation.
License
MIT
Metadata
Release files for django-user-sessions-ng 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_user_sessions_ng-0.1.7.tar.gz | 38.6 kB | Without provenance | Details for django_user_sessions_ng-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_user_sessions_ng-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for django_user_sessions_ng-0.1.7-py3-none-any.whl |
Total release size: 50.9 kB
Release files / django_user_sessions_ng-0.1.7.tar.gz
| Download URL | django_user_sessions_ng-0.1.7.tar.gz |
|---|---|
| Size | 38.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13c73a2198c24f87211200579285047b82f474c6ae793c2d205bfc89a4098391
|
|
BLAKE2b-256 checksum How to use checksums |
c7b1a3d9b5db196bdc9d0b2ae8965f76b02568782436e12e4e1648c9f2ac9a22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.18
|
Release files / django_user_sessions_ng-0.1.7-py3-none-any.whl
| Download URL | django_user_sessions_ng-0.1.7-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a9968ac5f2ca132351fb2e3566963a61b90a89a25f7a8bf3a73fdeadb2e51fb
|
|
BLAKE2b-256 checksum How to use checksums |
eed23e33416dfecaa3a74706c4dc2cc6f22b252c9fcded2b7ae0353d5e9195cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.18
|
Security for django-user-sessions-ng 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.