From 9287cdc0d743895ea31a62aa105915e3072d6353 Mon Sep 17 00:00:00 2001 From: juuso-j <68938778+juuso-j@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:13:15 +0200 Subject: [PATCH] Handle M2M relation content_types --- mobility_data/admin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mobility_data/admin.py b/mobility_data/admin.py index 6a63ed522..4a3912abb 100644 --- a/mobility_data/admin.py +++ b/mobility_data/admin.py @@ -37,13 +37,13 @@ def get_queryset(self, request): readonly_fields = ("id",) list_filter = ( - ("content_type__name", custom_titled_filter("Type Name")), + ("content_types__name", custom_titled_filter("Type Name")), "is_active", ("mobile_unit_group__name", custom_titled_filter("Group Name")), ) list_display = ( "unit_name", - "type_name", + "type_names", "group_name", ) search_fields = ( @@ -62,8 +62,8 @@ def unit_name(self, obj): else: return obj.name - def type_name(self, obj): - return obj.content_type.name + def type_names(self, obj): + return " ,".join([o.name for o in obj.content_types.all()]) def group_name(self, obj): if obj.mobile_unit_group is None: