From 580818aedffebce068728de1d36ffdb8447fee14 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 17 Aug 2018 19:31:14 +0200 Subject: Warehouse: fix division form int and save --- ishtar_common/wizards.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 6209a16c3..9a068063b 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -705,8 +705,11 @@ class Wizard(IshtarWizard): related_model = getattr(obj, model + 's') # manage through if hasattr(related_model, 'through') and related_model.through: - related_set_name = str( - related_model.through.__name__ + '_set').lower() + if hasattr(related_model.through, "RELATED_SET_NAME"): + related_set_name = related_model.through.RELATED_SET_NAME + else: + related_set_name = str( + related_model.through.__name__ + '_set').lower() if hasattr(obj, related_set_name): related_model = getattr(obj, related_set_name) # clear real m2m @@ -732,6 +735,9 @@ class Wizard(IshtarWizard): (field.related_model == related_model.model or isinstance(obj, field.related_model)): continue + if field.name in getattr( + related_model.through, 'RELATED_ATTRS', []): + continue related_data[field.name] = None if key not in m2m_items: @@ -1320,8 +1326,8 @@ class Wizard(IshtarWizard): # manage through through = False if hasattr(related, 'through') and related.through: - if hasattr(c_form, "form_through_name"): - related_set_name = c_form.form_through_name + if hasattr(related.through, "RELATED_SET_NAME"): + related_set_name = related.through.RELATED_SET_NAME else: related_set_name = str( related.through.__name__ + '_set').lower() -- cgit v1.2.3