django-audit
Django Audit is a simple Django app that tracks and logs requests to your application.
Quick Start
- Install django-audit
pip install dj-audit
- Add
dj_auditto your INSTALLED_APPS:
INSTALLED_APPS = [
...,
"dj_audit"
]
- Add
dj_auditmiddleware:
MIDDLEWARE = [
...
"dj_audit.middleware.AuditMiddleware"
]
if you want access to the dj-audit dashboard, then add the following to your urls.py
urlpatterns = [
path("admin/", admin.site.urls),
path("dj-audit/", include('dj_audit.urls'))
]
- Run migrate
python manage.py migrate
Management commands
flush_auditlog - Cleans up dj-audit AuditLog table
python manage.py flush_auditlog
Customizing dj-audit
You have a couple options available to you to customize dj-audit a bit. These should be defined in your settings.py file.
-
AUDIT_LOG_TEMPLATE: str: If set, the template here will be render when the user visits the audit log page (i.e /dj-audit/audit-logs/) -
REQUEST_STATUS_TEMPLATE: str: If set, the template here will be render when the user visits the request status page (i.e /dj-audit/request-status/) -
IGNORE_FILE_EXTENSIONS: list: If set, the middleware will not log endpoints containing the extensions specified in the list. DEFAULT:['.svg', '.js', '.css', '.png', '.jpg', '.ico'] -
AUDIT_LOG_DJ_REST_CONTENT_TYPES: list: content type of your Rest APIs. DEFAULT:['application/json', 'application/xml'] -
AUDIT_LOG_DJ_EXTRA_CONDITIONS_FOR_200: bool: Specify if there are extra conditions you will like to check to validate if a request is successful or not. DEFAULT:False -
AUDIT_LOG_DJ_EXTRA_CONDITIONS: list: Extra conditions to set to determine if a request body is successful or not. DEFAULT:[]
Test
make test
or with coverage
make coverage_test
Metadata
Release files for dj-audit 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dj_audit-0.1.4.tar.gz | 19.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dj_audit-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.8 kB
Release files / dj_audit-0.1.4.tar.gz
| Download URL | dj_audit-0.1.4.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
151e4ad23907b71ec0fb56a4bb3a9d01885d917ff186c8e4af869ac374420b9d
|
|
BLAKE2b-256 checksum How to use checksums |
9b48096bc0fdf7d78506b258efeb90cf94074018631cdc3bcd293f8c2f4dcec0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.2
|
Release files / dj_audit-0.1.4-py3-none-any.whl
| Download URL | dj_audit-0.1.4-py3-none-any.whl |
|---|---|
| Size | 23.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9800ac0d9d06f131be164c7e9dbe93c384522565d758bc3cea2c0c9491fd116
|
|
BLAKE2b-256 checksum How to use checksums |
d113f31fa3be7f7250bb20dd9b86f939758020aaba62fc0498e1149494c48d7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.2
|