From 7814cb0d8e147edf1efc6ec34225fac5c87d3206 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 20 Apr 2016 13:46:00 -0300 Subject: [PATCH] HOT FIX: checa se value is not None --- crispy_layout_mixin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crispy_layout_mixin.py b/crispy_layout_mixin.py index 89ce0048f..ad079f66a 100644 --- a/crispy_layout_mixin.py +++ b/crispy_layout_mixin.py @@ -55,6 +55,7 @@ def get_field_display(obj, fieldname): value = getattr(obj, 'get_%s_display' % fieldname)() else: value = getattr(obj, fieldname) + if value is None: display = '' elif 'date' in str(type(value)): @@ -62,7 +63,10 @@ def get_field_display(obj, fieldname): elif 'bool' in str(type(value)): display = _('Sim') if value else _('Não') elif 'ImageFieldFile' in str(type(value)): - display = ''.format(value.url) + if value: + display = ''.format(value.url) + else: + display = '' elif 'FieldFile' in str(type(value)): if value: display = '{}'.format(