From 123f44323becafffa0bb4cd5cecbcd85864dc191 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 21 Apr 2017 20:32:42 +0200 Subject: Fix wizard validations --- ishtar_common/wizards.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index e64d259e7..e8052c768 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -715,19 +715,22 @@ class Wizard(NamedUrlWizardView): # check if there is no missing fields # should be managed normally in forms but... - if hasattr(model._meta, 'get_fields'): # django 1.8 - fields = model._meta.get_field() - else: - fields = model._meta.fields + fields = model._meta.get_fields() + - has_problemetic_null = [ - (field.name, field.default == NOT_PROVIDED) - for field in fields + has_problemetic_null = False + for field in fields: if (field.name not in value - or not value[field.name]) - and not field.null and not field.blank - and (not field.default - or field.default == NOT_PROVIDED)] + or not value[field.name]) \ + and (hasattr(field, 'null') + and not field.null) \ + and (hasattr(field, 'blank') + and not field.blank) \ + and (hasattr(field, 'default') + and (not field.default + or field.default == NOT_PROVIDED)): + has_problemetic_null = True + break if has_problemetic_null: continue -- cgit v1.2.3