This django app intended for writing HTTP log to database and/or watch last user activity.
Features:
- DB router for writing logs to another database.
- Filters for ignoring some queries by URL, HTTP methods and response codes.
- Saving anonymous activity as fake user.
- Autocreation log DB (for postgresql)
Install:
$ pip install django-user-activity-log2
settings.py:
INSTALLED_APPS = (
...
'activity_log',
)
MIDDLEWARE_CLASSES = (
...
'activity_log.middleware.ActivityLogMiddleware',
)
# For writing log to another DB
DATABASE_ROUTERS = ['activity_log.router.DatabaseAppsRouter']
DATABASE_APPS_MAPPING = {'activity_log': 'logs'}
# If you set up DATABASE_APPS_MAPPING, but don't set related value in
# DATABASES, it will created automatically using "default" DB settings
# as example.
DATABASES = {
'logs': {
...
},
}
# Create DB automatically (for postgres, and may be mysql).
# We create log database automatically using raw SQL in pre_migrate signal.
# You must insure, that DB user has permissions for creation databases.
# Tested only for postgresql
ACTIVITYLOG_AUTOCREATE_DB = False
# App settings
# Log anonymous actions?
ACTIVITYLOG_ANONYMOUS = True
# Update last activity datetime in user profile. Needs updates for user model.
ACTIVITYLOG_LAST_ACTIVITY = True
# Only this methods will be logged
ACTIVITYLOG_METHODS = ('POST', 'GET')
# List of response statuses, which logged. By default - all logged.
# Don't use with ACTIVITYLOG_EXCLUDE_STATUSES
ACTIVITYLOG_STATUSES = (200, )
# List of response statuses, which ignores. Don't use with ACTIVITYLOG_STATUSES
# ACTIVITYLOG_EXCLUDE_STATUSES = (302, )
# URL substrings, which ignores
ACTIVITYLOG_EXCLUDE_URLS = ('/admin/activity_log/activitylog', )
account/models.py:
from django.contrib.auth.models import AbstractUser
from activity_log.models import UserMixin
# Only for LAST_ACTIVITY = True
class User(AbstractUser, UserMixin):
pass
$ python manage.py migrate & python manage.py migrate --database=logs
If you use ACTIVITYLOG_AUTOCREATE_DB migrations to logs database will be run automatically.
Metadata
Release files for django-user-activity-log2 0.0.25
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 | |
|---|---|---|---|---|
| django-user-activity-log2-0.0.25.tar.gz | 7.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_user_activity_log2-0.0.25-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.8 kB
Release files / django-user-activity-log2-0.0.25.tar.gz
| Download URL | django-user-activity-log2-0.0.25.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce3ac0659a1efdf9d3b3c592454ee3dd31304cc92ebdb67c021dcdd3d9d6de15
|
|
BLAKE2b-256 checksum How to use checksums |
2e2e910d43e8588581a62d6b061b2642132503acafcb33143b96abab218adb32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|
Release files / django_user_activity_log2-0.0.25-py3-none-any.whl
| Download URL | django_user_activity_log2-0.0.25-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b07681b9ffc6e7e5658f57a0d43e0b92151a862b8bfa994e95f2258b458c2f94
|
|
BLAKE2b-256 checksum How to use checksums |
29467d8a5828ed87c98b7df37a89cf9ec4c00e531e4e70a636371104a8a594b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|
Security for django-user-activity-log2 0.0.25
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.