Skip to content

admin

django_spire.history.admin

HistoryEventAdmin

Bases: ModelAdmin

list_display = ('id', 'content_object_link', 'content_type', 'created_datetime', 'event_verbose') class-attribute instance-attribute

list_filter = ('event', 'created_datetime') class-attribute instance-attribute

search_fields = ('id', 'content_type__model') class-attribute instance-attribute

ordering = ('-created_datetime',) class-attribute instance-attribute

Source code in django_spire/history/admin.py
def content_object_link(self, history_event: models.HistoryEvent) -> str:
    url = reverse(
        f'admin:{history_event.content_type.app_label}_{history_event.content_type.model}_change',
        args=[history_event.object_id]
    )

    return format_html(f'<a href="{url}">{history_event.content_object}</a>')