Coder Social home page Coder Social logo

blazskills / django-audit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emmarex/django-audit

0.0 1.0 0.0 95 KB

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

Home Page: https://pypi.org/project/dj-audit/

License: Apache License 2.0

Python 66.79% Makefile 2.56% CSS 2.45% JavaScript 0.35% HTML 27.86%

django-audit's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.