diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-09-05 16:42:12 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-09-05 16:42:12 +0200 | 
| commit | 466195bd302ffcabdbcbbef882a269093584d865 (patch) | |
| tree | 2f834d0259ae11f4d05f176bb98d9c2084937027 | |
| parent | 1db01464e219590133e9b7d30d9d1a32172ef0e3 (diff) | |
| download | Ishtar-466195bd302ffcabdbcbbef882a269093584d865.tar.bz2 Ishtar-466195bd302ffcabdbcbbef882a269093584d865.zip  | |
Fix form initialization
| -rw-r--r-- | ishtar_common/forms.py | 14 | 
1 files changed, 12 insertions, 2 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 79ca2c360..b0e8cb43c 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -207,7 +207,12 @@ class ManageOldType(object):                  if prefix not in k:                      continue                  new_k = k[len(prefix) + 1:] -                for val in kwargs['data'].getlist(k): +                items = [] +                if hasattr(kwargs['data'], 'getlist'): +                    items = kwargs['data'].getlist(k) +                else: +                    items = [kwargs['data'][k]] +                for val in items:                      if not val:                          continue                      if new_k not in self.init_data: @@ -216,7 +221,12 @@ class ManageOldType(object):          if 'initial' in kwargs and kwargs['initial']:              for k in kwargs['initial']:                  if k not in self.init_data or not self.init_data[k]: -                    for val in kwargs['initial'].getlist(k): +                    items = [] +                    if hasattr(kwargs['initial'], 'getlist'): +                        items = kwargs['initial'].getlist(k) +                    else: +                        items = [kwargs['initial'][k]] +                    for val in items:                          if not val:                              continue                          if k not in self.init_data:  | 
