Skip to content

Commit 6edf16c

Browse files
committed
small MapField bugfixes
1 parent 9e02487 commit 6edf16c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mongodbforms/documents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def _post_clean(self):
360360
value = getattr(self.instance, f.name)
361361
if f.name not in exclude:
362362
f.validate(value)
363-
elif value == '' or value == []:
363+
elif value is not False and not value: # in case of '' or [] or {}
364364
# mongoengine chokes on empty strings for fields
365365
# that are not required. Clean them up here, though
366366
# this is maybe not the right place :-)

mongodbforms/widgets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def render(self, name, value, attrs=None):
163163
id_ = final_attrs.get('id', None)
164164
fieldset_attr = {}
165165

166-
value = value.items()
166+
value = list(value.items()) # in Python 3.X dict.items() returns dynamic *view objects*
167167
value.append(('', ''))
168168
for i, (key, widget_value) in enumerate(value):
169169
if id_:
@@ -222,4 +222,4 @@ def __deepcopy__(self, memo):
222222
return obj
223223

224224

225-
225+

0 commit comments

Comments
 (0)