Skip to main content

Django Audit is a simple Django app that tracks and logs requests to your application.

Project description

django-audit

GitHub issues PyPI - Downloads codecov CodeCov pre-commit

Django Audit is a simple Django app that tracks and logs requests to your application.

Quick Start

  1. Install django-audit
pip install dj-audit
  1. Add dj_audit to your INSTALLED_APPS:
INSTALLED_APPS = [
    ...,
    "dj_audit"
]
  1. Add dj_audit middleware:
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'))
]
  1. 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

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

dj_audit-0.1.3.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_audit-0.1.3-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file dj_audit-0.1.3.tar.gz.

File metadata

  • Download URL: dj_audit-0.1.3.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/30.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.2.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.2

File hashes

Hashes for dj_audit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9b50b2f8c3c601b88ca9926206ccf09a22abf55f4e817240957fcc6841f4e234
MD5 84e372fc5be679ad38a6491515a17fe8
BLAKE2b-256 78779522683dd8134b456430320f13506eda889bcd1c5dadb91c6beb27a47c82

See more details on using hashes here.

File details

Details for the file dj_audit-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dj_audit-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/30.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.2.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.2

File hashes

Hashes for dj_audit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f0aac6e3abb706142dd2699f308b133f319d9e869f6ed7f174781c0fb3f12a92
MD5 f42b793c917288b103d296bdd23cd1fe
BLAKE2b-256 66c78efdbb3736436647915a9a520f7074154a1f75bdc77331e04fab13149d2b

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