From 93f31fbaa08e070ebd688e888225651f64c7f4ca Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 19 Jan 2021 09:08:59 +0100 Subject: [PATCH] even more beauty: using verbose_name from model for display data --- evapp/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/evapp/views.py b/evapp/views.py index 62de163..c2acc72 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -82,11 +82,14 @@ class EvaFormView(CookieWizardView): # def beautify_data(self, data): - # update data with keys from *_CHOICES if present there + # update values in data dictionary with keys from *_CHOICES if present there choices = {**DEPARTMENT_CHOICES, **LAPTOP_CHOICES, **TRANSPONDER_CHOICES, **OS_CHOICES, **MOBILE_CHOICES, **LANG_CHOICES,} data.update({k:choices[v] for k,v in data.items() \ if isinstance(v,collections.abc.Hashable) \ and v in choices}) - return data + # replace keys in data dictionary with verbose_name + newdata = {self.instance._meta.get_field(k).verbose_name.title() : v for k,v in data.items()} + + return newdata