Browse Source

Corrige interpret do que é field e do que é value

pull/979/head
LeandroRoberto 8 years ago
parent
commit
78e34ba2de
  1. 16
      sapl/crispy_layout_mixin.py

16
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))

Loading…
Cancel
Save