Skip to content

Commit

Permalink
Fix Exception: Cannot find reverse relation for model
Browse files Browse the repository at this point in the history
SQLAlchemy 2.0.2 removed the invocation of registry.configure() from
Mapper.iterate_properties causing this problem.

https://docs.sqlalchemy.org/changelog/changelog_20.html#change-45fe5664c88893d899c991ca3675142c

Observed as test failures in:

flask_admin/tests/sqla/test_basic.py
flask_admin/tests/sqla/test_form_rules.py
flask_admin/tests/sqla/test_inlineform.py
  • Loading branch information
cjmayo committed Oct 29, 2023
1 parent 14e24c9 commit 87f87f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flask_admin/contrib/sqla/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def get_form(model, converter,
mapper = model._sa_class_manager.mapper
field_args = field_args or {}

properties = ((p.key, p) for p in mapper.iterate_properties)
properties = ((p.key, p) for p in mapper.attrs)

if only:
def find(name):
Expand Down
2 changes: 1 addition & 1 deletion flask_admin/contrib/sqla/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _get_model_iterator(self, model=None):
if model is None:
model = self.model

return model._sa_class_manager.mapper.iterate_properties
return model._sa_class_manager.mapper.attrs

def _apply_path_joins(self, query, joins, path, inner_join=True):
"""
Expand Down

0 comments on commit 87f87f0

Please sign in to comment.