diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-11-26 19:02:08 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-11-26 19:02:08 +0100 |
commit | f7a54d5ee7c111da1819e1e92d4e5957d31c4e48 (patch) | |
tree | f028fad6eb36cbf2a7548941f8c40f0cc834c8f4 /ishtar_common/wizards.py | |
parent | a5f26c1d33e57b2fa470db829fb76105cddfa89a (diff) | |
download | Ishtar-f7a54d5ee7c111da1819e1e92d4e5957d31c4e48.tar.bz2 Ishtar-f7a54d5ee7c111da1819e1e92d4e5957d31c4e48.zip |
Wizard: allow callable to be keys
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r-- | ishtar_common/wizards.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 21cfa6ceb..180ed4618 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -408,6 +408,8 @@ class Wizard(NamedUrlWizardView): return self.render(form_list[-1]) for dependant_item in other_objs: c_item = getattr(obj, dependant_item) + if callable(c_item): + c_item = c_item() # manage ManyToMany if only one associated if hasattr(c_item, "all"): c_items = c_item.all() @@ -781,10 +783,12 @@ class Wizard(NamedUrlWizardView): if base_model: key = base_model + 's' initial.setlist(base_field, [ - unicode(val.pk) for val in getattr(obj, key).all()]) + unicode(val.pk) for val in getattr(value, key).all()]) else: fields = base_field.split('__') for field in fields: + if callable(value): + value = value() if not hasattr(value, field) or \ getattr(value, field) is None: value = obj |