Skip to content

Instantly share code, notes, and snippets.

View hovi's full-sized avatar

Karel Hovorka hovi

View GitHub Profile
@hovi
hovi / listlinksmixin.py
Last active August 24, 2020 07:20 — forked from Vigrond/listlinksmixin.py
A Django Admin Mixin that supports foreign key and many-to-many relationship links with list_display_fk_clickthrough and list_display_m2m_clickthrough attribute
class ListDisplayClickthroughMixin(object):
list_display_fk_clickthrough = []
list_display_m2m_clickthrough = []
def __init__(self, *args, **kwargs):
super(ListDisplayClickthroughMixin, self).__init__(*args, **kwargs)
for field in self.list_display_fk_clickthrough or []:
self.bind_field(field, fk_link_fnc)
for field in self.list_display_m2m_clickthrough or []: