Skip to content

Instantly share code, notes, and snippets.

@jdklub
jdklub / admin.py
Last active November 22, 2023 11:25
Edit a many-to-many relationship (ManyToManyField) on the Django Admin change list page.
class BookChangeList(ChangeList):
def __init__(self, request, model, list_display, list_display_links,
list_filter, date_hierarchy, search_fields, list_select_related,
list_per_page, list_max_show_all, list_editable, model_admin):
super(BookChangeList, self).__init__(request, model, list_display, list_display_links,
list_filter, date_hierarchy, search_fields, list_select_related,
list_per_page, list_max_show_all, list_editable, model_admin)
# these need to be defined here, and not in BookAdmin