No project description provided
Project description
Django Auditlog
This project is totally based in Django Auditlog library.
Instalation
with pip
pip install django-federation-auditlog
with pipenv
pipenv install django-federation-auditlog
with poetry
poetry add django-federation-auditlog
Adding Django Federation Auditlog to your Django application
To use in your application, just add 'django-federation-auditlog' to your project’s INSTALLED_APPS setting and add 'AuditlogMiddleware' to your's MIDDLEWARE setting then run manage.py migrate to create/upgrade the necessary database structure.
INSTALLED_APPS = [
# other apps
"django_federation_auditlog",
]
and
MIDDLEWARE = [
# others middlewares
"django_federation_auditlog.middleware.AuditlogMiddleware",
]
Then run
python manage.py migrate
Usage
Auditlog can automatically log changes to objects for you. This functionality is based on Django’s signals, but linking your models to Django Federation Auditlog is even easier using signals.
from django.db import models
from django_federation_auditlog.registry import auditlog
class MyModel(models.Model):
pass
# Model definition goes here
auditlog.register(MyModel)
It is recommended to place the register code (auditlog.register(MyModel)) at the bottom of your models.py file.
OBS: If .save()
be called to a model and the fields have the same value, log entries don't
be generated.
Including Fields
If include_fields
is specified, only the fields with the given names will be included in the generated log entries.
For example, to include only the field name
from class MyModel, use:
from django.db import models
from django_federation_auditlog.registry import auditlog
class MyModel(models.Model):
name = models.CharField()
description = models.CharField()
# Model definition goes here
auditlog.register(MyModel, include_fields=["name"])
Excluding fields
Fields that are excluded will not trigger saving a new log entry and will not show up in the recorded changes.
If exclude_fields
is specified the fields with the given names will not be included in the generated log entries.
For example, to exclude the field description
, use:
from django.db import models
from django_federation_auditlog.registry import auditlog
class MyModel(models.Model):
name = models.CharField()
description = models.CharField()
# Model definition goes here
auditlog.register(MyModel, exclude_fields=["description"])
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
Built Distribution
File details
Details for the file django_federation_auditlog-1.1.0.tar.gz
.
File metadata
- Download URL: django_federation_auditlog-1.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b0310f7625fa46b487812facf77ee350b4fb7c513adb4fe8d27eec4f64a567a |
|
MD5 | 1d6516981058a610bee13b8e63a9b230 |
|
BLAKE2b-256 | fcbdea3c44866e138a3b55c09121a5b0c85e9578f67370deeb70e50809677774 |
File details
Details for the file django_federation_auditlog-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_federation_auditlog-1.1.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fb04e057f673107e604f60f5bcfadb3ea5e0cf9892e5bf3efbdb31208c52b6e |
|
MD5 | 1c40aff0d51a39d48dad3c602145cb78 |
|
BLAKE2b-256 | 7833c7aba409de1f00391bc9dfc6956b7179cf50d97606de5c32310e2210a3c5 |