From 78e34ba2de7f89060eebbb88a79e021b94bf0ad6 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Thu, 23 Mar 2017 09:27:44 -0300 Subject: [PATCH] =?UTF-8?q?Corrige=20interpret=20do=20que=20=C3=A9=20field?= =?UTF-8?q?=20e=20do=20que=20=C3=A9=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/crispy_layout_mixin.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py index 82bc2538a..e9dbc3f01 100644 --- a/sapl/crispy_layout_mixin.py +++ b/sapl/crispy_layout_mixin.py @@ -65,15 +65,17 @@ def get_field_display(obj, fieldname): ele pode ser um aggregate, annotate, um property, um manager, ou mesmo uma método no model. """ - field = getattr(obj, fieldname) - - verbose_name = str(field.verbose_name)\ - if hasattr(field, 'verbose_name') else '' + value = getattr(obj, fieldname) + verbose_name = '' - if hasattr(field, 'choices') and field.choices: - value = getattr(obj, 'get_%s_display' % fieldname)() else: - value = getattr(obj, fieldname) + verbose_name = str(field.verbose_name)\ + if hasattr(field, 'verbose_name') else '' + + if hasattr(field, 'choices') and field.choices: + value = getattr(obj, 'get_%s_display' % fieldname)() + else: + value = getattr(obj, fieldname) str_type = str(type(value))