Can I track django_admin_log through a Django admin?

The django_admin_log table django_admin_log useful for monitoring user actions in the admin. Right now I can achieve this by directly contacting the database. Is there any built-in functionality where I can view the django_admin_log table through Django admin for all users?

+4
source share
2 answers

You cannot just:

 from django.contrib.admin.models import LogEntry admin.site.register(LogEntry) 

In one of your admin.py files? I just tested it and it is simple, but it works.

You can be more specific and create a ModelAdmin class for LogEntry to provide a better view of the list and possibly some filtering capabilities. But that should work.

+7
source

Here is my version. Link to available fields.

 class LogAdmin(admin.ModelAdmin): """Create an admin view of the history/log table""" list_display = ('action_time','user','content_type','change_message','is_addition','is_change','is_deletion') list_filter = ['action_time','user','content_type'] ordering = ('-action_time',) #We don't want people changing this historical record: def has_add_permission(self, request): return False def has_change_permission(self, request, obj=None): #returning false causes table to not show up in admin page :-( #I guess we have to allow changing for now return True def has_delete_permission(self, request, obj=None): return False 
+7
source

Source: https://habr.com/ru/post/1300923/


All Articles