django-user-activity
A reusable Django app for tracking user activity on web application. This app logs user actions like url, referer, method, ip, user_agent and timestamp. It’s designed to be reusable, easy to integrate, and can be customized to fit your needs.
Features
- Tracks user activity (e.g., URL visited, HTTP method, referer, ip, user_agent and timestamp).
- Logs activity for authenticated users.
- Easily integrates into any Django project.
- Admin interface for easy viewing and management of activity data.
- Reusable and customizable.
Requirements
- Python 3.x
- Django 4.0 or later (recommended)
- A PostgreSQL, MySQL, SQLite or any relational database for data storage
Installation
You can install the django-user-activity app in your Django project using one of the following methods.
Option 1: Install via PyPi
-
Install the app via
pip:pip install django-user-activity
Option 2: Install via Github
-
Install the app via
git:pip install git+https://github.com/rkpust/django-user-activity
Option 3: Install from Local Directory
-
Clone the repository or download the package.
-
Navigate to the project directory and install the app locally.
pip install -e /path/to/django-user-activity pip install django-user-activity-0.0.1.tar.gz
Configuration
Add activity to your INSTALLED_APPS in your settings.py file:
INSTALLED_APPS = [
...
'activity',
...
]
Add ActivityMiddleware to your MIDDLEWARE in your settings.py file:
MIDDLEWARE = [
...
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'activity.middleware.ActivityMiddleware',
...
]
Run migrations to set up the necessary database tables:
python manage.py makemigrations
python manage.py migrate
Or, you can run these commands for further clarification.
python manage.py makemigrations activity
python manage.py migrate activity 0001
Activity Model
The Activity model contains the following fields:
user: The user who performed the action.
url: The URL visited by the user.
referer: The referer tells you which page the user is coming from. If its value is None, it means the user hits the url directly in the browser.
method: The HTTP method (e.g., GET, POST).
ip: The ip of user's device.
user_agent: The user_agent tells you the information of users browser, os etc information.
timestamp: The timestamp when the action occurred.
Admin Interface
You can view, filter, and search user activity data in the Django Admin Interface by visiting /admin path. Here, you will see Activities option in the left side. You will
- see those field as list.
user,url,referer,method,ip,user_agent,timestamp - filter those field.
method,timestamp - search those field by value.
username,url,referer,method,ip
License
This project is licensed under the MIT License - see the LICENSE file for details.
How to Contribute
Contributions are welcome! If you'd like to improve, fix bugs or add new features to the reusable django-user-activity app, feel free to create an issue or submit a pull request on GitHub. Ensure the code adheres to the project’s style.
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Write your code and tests.
- Run the tests to ensure everything is working. (
python manage.py test activity) - Submit a pull request describing your changes.
Metadata
Release files for django-user-activity 0.0.1
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_activity-0.0.1.tar.gz | 6.1 kB | Without provenance | Details for django_user_activity-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_user_activity-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for django_user_activity-0.0.1-py3-none-any.whl |
Total release size: 13.1 kB
Release files / django_user_activity-0.0.1.tar.gz
| Download URL | django_user_activity-0.0.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
797a33ab22e694c9d7fe564055e758fb72f1ae1f3d2faf1ae7c1e8272ae34c5e
|
|
BLAKE2b-256 checksum How to use checksums |
6f0d5a470d19612a28fb3226d995bfb3f4a4e71b1cd3de9300a6d8a179e8d34b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Release files / django_user_activity-0.0.1-py3-none-any.whl
| Download URL | django_user_activity-0.0.1-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2695bc2dd8872b761b2d16d68e48453b86d12b79a91df7f9e97a811b0958f4f8
|
|
BLAKE2b-256 checksum How to use checksums |
2ad826fb533158f3ac733f0af3bc96192eee3dc5996e9e2b63ec3742a97094e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Security for django-user-activity 0.0.1
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.