Skip to content

Instantly share code, notes, and snippets.

@malikalbeik
Last active February 4, 2020 13:27
Show Gist options
  • Save malikalbeik/0c7f8f42e1d6fa2823c85e59920aca8e to your computer and use it in GitHub Desktop.
Save malikalbeik/0c7f8f42e1d6fa2823c85e59920aca8e to your computer and use it in GitHub Desktop.
Register Django's LogEntry model in Django Admin.
from django.contrib.admin.models import LogEntry
@admin.register(LogEntry)
class LogEntryAdmin(admin.ModelAdmin):
# to have a date-based drilldown navigation in the admin page
date_hierarchy = 'action_time'
# to filter the resultes by users, content types and action flags
list_filter = [
'user',
'content_type',
'action_flag'
]
# when searching the user will be able to search in both object_repr and change_message
search_fields = [
'object_repr',
'change_message'
]
list_display = [
'action_time',
'user',
'content_type',
'action_flag',
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment