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.1.tar.gz (7.2 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.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_device_tracker-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 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.1.tar.gz
Algorithm Hash digest
SHA256 10df6277693940134a763af7f9033f666fcd4c49f5676b8badf271d76e91a607
MD5 259e64de603d575bca90978ce4daecac
BLAKE2b-256 ac9fc7fa9bedf0cf89227abc164b18229482e0166d43ab7931143bf7cbff5fd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_device_tracker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 868f31708f8792c6e46304ba4426360751befa8fb0ca06bc7b29ae3c38b5f6fc
MD5 0edc9ca1ef52f5c3a455dc5971224979
BLAKE2b-256 f10989737972a941507acb079d0af711d0f9b51b4803c812582eef2962fa0992

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