Skip to main content

Reusable device tracking app for Django projects

Project description

Django Device Tracker

A reusable Django app to track user login devices — plug-and-play for any Django project using session or JWT-based authentication.


🔧 Features

  • Track IP address and user-agent per login
  • Compatible with JWT (e.g., simplejwt)
  • Saves login timestamp and refresh token jti
  • Admin panel support
  • Lightweight, no external dependencies

📦 Installation

pip install django-device-tracker

Add to your INSTALLED_APPS:

INSTALLED_APPS += ["device_tracker"]

Apply migrations:

python manage.py migrate device_tracker

🚀 Usage

Manual tracking per login (JWT):

In your login/signup/OTP views:

from device_tracker.utils import track_device

# After creating refresh token:
track_device(request, user, refresh_token)

The refresh_token is optional but strongly recommended for managing sessions.

What it stores:

  • user: ForeignKey to your user model
  • ip_address: Auto-resolved from request headers
  • device_name: User-Agent header
  • refresh_token_jti: Extracted from token if provided
  • last_seen: Timestamp of login
  • is_active: Boolean flag (you can control this)

🛠 Admin Support

Device tracking entries are available in Django admin under Device model.


🔍 Advanced Integration Ideas (Optional)

  • Custom middleware to track every request or session
  • Show user active devices (build your own API/view)
  • Revoke session by removing device entry or blacklisting token

📂 Development

To install locally:

git clone https://github.com/yourusername/django-device-tracker.git
cd django-device-tracker
pip install -e .

🪪 License

MIT License. See LICENSE file.


✍️ Author

Developed by [mejomba]. Contributions and feedback welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_device_tracker-0.1.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_device_tracker-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file django_device_tracker-0.1.2.tar.gz.

File metadata

  • Download URL: django_device_tracker-0.1.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for django_device_tracker-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c6ba7af6d10b77f59e2944d8e585d92d1b05939a89ff7ac9cf5bf4aa8accd31a
MD5 1ea998148eb6db591055068cdd867f30
BLAKE2b-256 e7bb297bbda05de4ef353f4a3a03bcbe2ab8d0caa90974f6fa745914798010e3

See more details on using hashes here.

File details

Details for the file django_device_tracker-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_device_tracker-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8dfea42ddde2ddb3b7d5fa81135121a5d0289fe45dbc57bc010b8afa59e62d44
MD5 6ecd3b0fa88dd7412688fcd959d063d8
BLAKE2b-256 0ddd9c9c10e81ced4a2825d93aa5ce3cf0fc8ed3b0ca0e4fd15e7b6d48957f43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page