Made change in following code (** new code marked **) and issue seems fixed (maybe I have done something wrong which requires this fix:
def _value_for_db_collection(self, value, field, field_kind, db_type,
lookup):
subfield, subkind, db_subtype = self._convert_as(field.item_field,
lookup)
# Do convert filter parameters.
if lookup:
# Special case where we are looking for an empty list
if lookup == 'exact' and db_type == 'list' and value == u'[]':
return []
value = self._value_for_db(value, subfield,
subkind, db_subtype, lookup)
# Convert list/set items or dict values.
else:
if field_kind == 'DictField':
# Generator yielding pairs with converted values.
value = (
(key, self._value_for_db(subvalue, subfield,
subkind, db_subtype, lookup))
for key, subvalue in value.iteritems())
# Return just a dict, a once-flattened list;
if db_type == 'dict':
return dict(value)
elif db_type == 'list':
return list(item for pair in value for item in pair)
else:
# Generator producing converted items.
value = (
self._value_for_db(subvalue, subfield,
subkind, db_subtype, lookup)
for subvalue in value)
# "list" may be used for SetField.
if db_type in 'list':
return list(value)
elif db_type == 'set':
# assert field_kind != 'ListField'
return set(value)
# Pickled formats may be used for all collection fields,
# the fields "natural" type is serialized (something
# concrete is needed, pickle can't handle generators :-)
if db_type == 'bytes':
return pickle.dumps(field._type(value), protocol=2)
elif db_type == 'string':
return pickle.dumps(field._type(value))
# If nothing matched, pass the generator to the back-end.
#****************NEW CODE - begin **********************
import types
if type(value) is types.GeneratorType:
value = list(value)
#****************NEW CODE - end****************************
return value