From 07c21b9c79d0942e99ea1d316074a2de8f540e53 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sun, 11 Aug 2019 23:46:09 +0200 Subject: [PATCH] Add subtitle to admin --- media/admin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/media/admin.py b/media/admin.py index 47d19d2..945d891 100644 --- a/media/admin.py +++ b/media/admin.py @@ -18,7 +18,7 @@ class AuteurAdmin(VersionAdmin): class MediaAdmin(VersionAdmin): - list_display = ('title', 'authors_list', 'side_identifier', 'isbn', + list_display = ('full_name', 'authors_list', 'side_identifier', 'isbn', 'external_link') search_fields = ('title', 'authors__nom', 'side_identifier', 'subtitle', 'isbn') @@ -26,6 +26,14 @@ class MediaAdmin(VersionAdmin): date_hierarchy = 'publish_date' form = MediaAdminForm + def full_name(self, obj): + if obj.subtitle: + return "{} : {}".format(obj.title, obj.subtitle) + else: + return obj.title + + full_name.short_description = _('name') + def authors_list(self, obj): return ", ".join([a.nom for a in obj.authors.all()])