A Django app for tracking user activity
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_user_activity-0.0.1.tar.gz.
File metadata
- Download URL: django_user_activity-0.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
797a33ab22e694c9d7fe564055e758fb72f1ae1f3d2faf1ae7c1e8272ae34c5e
|
|
| MD5 |
5bf39c57c8620011d3e3c1b18ae1b42e
|
|
| BLAKE2b-256 |
6f0d5a470d19612a28fb3226d995bfb3f4a4e71b1cd3de9300a6d8a179e8d34b
|
File details
Details for the file django_user_activity-0.0.1-py3-none-any.whl.
File metadata
- Download URL: django_user_activity-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2695bc2dd8872b761b2d16d68e48453b86d12b79a91df7f9e97a811b0958f4f8
|
|
| MD5 |
e6322355056049c10ac9883b1f09bcd4
|
|
| BLAKE2b-256 |
2ad826fb533158f3ac733f0af3bc96192eee3dc5996e9e2b63ec3742a97094e1
|