diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py index 34ae391e9..40f6b01e4 100644 --- a/sapl/crispy_layout_mixin.py +++ b/sapl/crispy_layout_mixin.py @@ -1,12 +1,12 @@ from math import ceil -import rtyaml from crispy_forms.bootstrap import FormActions from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit from django import template from django.utils import formats from django.utils.translation import ugettext as _ +import rtyaml def heads_and_tails(list_of_lists): @@ -50,8 +50,9 @@ class SaplFormLayout(Layout): def get_field_display(obj, fieldname): field = obj._meta.get_field(fieldname) - verbose_name = str(field.verbose_name) - if field.choices: + 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) @@ -74,6 +75,14 @@ def get_field_display(obj, fieldname): value.name.split('/')[-1:][0]) else: display = '' + elif 'ManyRelatedManager' in str(type(value))\ + or 'RelatedManager' in str(type(value)): + display = '