mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-03 05:04:43 +00:00
Shave off two SELECT COUNT(*) from admin page
This commit is contained in:
parent
5ba554af56
commit
2ae401a04f
1 changed files with 12 additions and 0 deletions
|
|
@ -1,9 +1,19 @@
|
|||
from django.contrib import admin
|
||||
from django.core.paginator import Paginator
|
||||
|
||||
from .models import LogEntry
|
||||
from .mixins import LogEntryAdminMixin
|
||||
from .filters import ResourceTypeFilter
|
||||
|
||||
|
||||
class NoCountPaginator(Paginator):
|
||||
PAGE_COUNT = 10000 # a large number
|
||||
|
||||
@property
|
||||
def count(self):
|
||||
return self.per_page * self.PAGE_COUNT
|
||||
|
||||
|
||||
class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
|
||||
list_display = ['created', 'resource_url', 'action', 'msg_short', 'user_url']
|
||||
search_fields = ['timestamp', 'object_repr', 'changes', 'actor__first_name', 'actor__last_name']
|
||||
|
|
@ -14,6 +24,8 @@ class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
|
|||
('Changes', {'fields': ['action', 'msg']}),
|
||||
]
|
||||
list_select_related = ['actor', 'content_type']
|
||||
show_full_result_count = False
|
||||
paginator = NoCountPaginator
|
||||
|
||||
|
||||
admin.site.register(LogEntry, LogEntryAdmin)
|
||||
|
|
|
|||
Loading…
Reference in a new issue