From 9ead7a5ac3fc8b83b95f8ed4558d92809f19805f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 16 Feb 2018 15:48:07 +0100 Subject: Wizard: get formated data with new Django API for Options --- ishtar_common/wizards.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 114b47712..cffaac271 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1253,19 +1253,24 @@ class DeletionWizard(Wizard): if not self.current_obj: return datas res = {} - for field in self.model._meta.fields + self.model._meta.many_to_many: + for field in self.model._meta.get_fields(): if field.name not in self.fields: continue value = getattr(self.current_obj, field.name) if not value: continue + label = "" + if hasattr(field, 'verbose_name'): + label = field.verbose_name if hasattr(value, 'all'): + if not label and hasattr(field, 'related_model'): + label = field.related_model._meta.verbose_name_plural value = ", ".join([unicode(item) for item in value.all()]) if not value: continue else: value = unicode(value) - res[field.name] = (field.verbose_name, value, '') + res[field.name] = (label, value, '') if not datas and self.fields: datas = [['', []]] for field in self.fields: -- cgit v1.2.3