Log entries are automatically created by the Django framework whenever a user adds, changes or deletes objects through the admin interface.
Django Admin Logs is a package that allows you to either view the admin log entries from within the admin interface, or to disable them entirely.
- Python 3.8+
- Django 4.2+
Install the package from PyPI:
pip install django-admin-logsThen add it to your INSTALLED_APPS in the settings file:
INSTALLED_APPS = (
...
'django_admin_logs',
...
)By default, Django Admin Logs enables log entries to be viewed from within
the admin interface but does not allow them to be deleted. Either of these
options can be configured by adding the following to your settings file.
DJANGO_ADMIN_LOGS_DELETABLE = TrueThis allows a superuser, or any staff user with the delete_logentry permission, to delete log entries from within the admin interface.
DJANGO_ADMIN_LOGS_ENABLED = FalseThis disables admin log entries so that they are no longer created by the Django framework or viewable from within the admin interface.
By default, Django creates log entries with the message "No fields changed" when an unchanged object is saved in the admin interface. To prevent such log entries from being created use the following setting:
DJANGO_ADMIN_LOGS_IGNORE_UNCHANGED = TrueFrom the local project directory, activate the virtual environment and install the development requirements:
pip install -e .[dev]To run tests for the installed version of Python and Django using pytest:
pytestTo run tests for all supported Python and Django versions using tox:
toxTo run tests for specific versions e.g. Python 3.10 and Django 4.2:
tox -e py310-django42