Issue with collection_class in relationship
bpbp-boop opened this issue · comments
Hi!
I'm trying to implement a similar model from the following simple example:
http://docs.sqlalchemy.org/en/rel_0_9/_modules/examples/adjacency_list/adjacency_list.html
When I add the "collection_class=attribute_mapped_collection('name')" to the children relationship, superadmin fails with the following error when adding a new row
Traceback (most recent call last):
File "/home/boden/nextgame-env/site-packages/flask_superadmin/model/base.py", line 242, in add
instance = self.save_model(self.model(), form, adding=True)
File "/home/boden/nextgame-env/site-packages/flask_superadmin/model/backends/sqlalchemy/view.py", line 67, in save_model
form.populate_obj(instance)
File "/home/boden/nextgame-env/site-packages/wtforms/form.py", line 79, in populate_obj
field.populate_obj(obj, name)
File "/home/boden/nextgame-env/site-packages/wtforms/fields/core.py", line 298, in populate_obj
setattr(obj, name, self.data)
File "/home/boden/nextgame-env/site-packages/sqlalchemy/orm/attributes.py", line 220, in __set__
instance_dict(instance), value, None)
File "/home/boden/nextgame-env/site-packages/sqlalchemy/orm/attributes.py", line 975, in set
lambda adapter, i: adapter.adapt_like_to_iterable(i))
File "/home/boden/nextgame-env/site-packages/sqlalchemy/orm/attributes.py", line 991, in _set_iterable
new_values = list(adapter(new_collection, iterable))
File "/home/boden/nextgame-env/site-packages/sqlalchemy/orm/collections.py", line 1533, in _convert
for incoming_key, value in util.dictlike_iteritems(dictlike):
File "/home/boden/nextgame-env/site-packages/sqlalchemy/util/langhelpers.py", line 1032, in dictlike_iteritems
"Object '%r' is not dict-like" % dictlike)
TypeError: Object '[]' is not dict-like
It looks like the Flask-Admin people had a similar issue a while back if that gives any clues:
https://github.com/mrjoes/flask-admin/issues/275