Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable admin interface from settings.py #643

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion auditlog/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import cached_property

from django.conf import settings
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.utils.translation import gettext_lazy as _
Expand All @@ -9,7 +10,6 @@
from auditlog.models import LogEntry


@admin.register(LogEntry)
class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
list_select_related = ["content_type", "actor"]
list_display = [
Expand Down Expand Up @@ -57,3 +57,7 @@ def has_delete_permission(self, request, obj=None):
def get_queryset(self, request):
self.request = request
return super().get_queryset(request=request)


if not settings.AUDITLOG_DISABLE_ADMIN_INTERFACE:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change the settings name to AUDITLOG_ENABLE_ADMIN_INTERFACE with default value of True

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Makes sense

admin.site.register(LogEntry, LogEntryAdmin)
5 changes: 5 additions & 0 deletions auditlog/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
settings, "AUDITLOG_DISABLE_ON_RAW_SAVE", False
)

# Disable django admin interface
settings.AUDITLOG_DISABLE_ADMIN_INTERFACE = getattr(
settings, "AUDITLOG_DISABLE_ADMIN_INTERFACE", False
)

# CID

settings.AUDITLOG_CID_HEADER = getattr(
Expand Down
7 changes: 7 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,10 @@ Django Admin integration

When ``auditlog`` is added to your ``INSTALLED_APPS`` setting a customized admin class is active providing an enhanced
Django Admin interface for log entries.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add .. versionadded:: 3.1.0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

If you want to not register the django admin interface, you can set the following setting:

.. code-block:: python

AUDITLOG_DISABLE_ADMIN_INTERFACE = True