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(