diff --git a/flask_admin/contrib/sqla/form.py b/flask_admin/contrib/sqla/form.py index bd99744ac..3e694a086 100644 --- a/flask_admin/contrib/sqla/form.py +++ b/flask_admin/contrib/sqla/form.py @@ -670,6 +670,13 @@ def _calculate_mapping_key_pair(self, model, info): reverse_prop = None for prop in target_mapper.iterate_properties: + try: + # Loading the mapper property will populate a lazy direction + # attribute + prop.mapper + except AttributeError: + continue + if hasattr(prop, 'direction') and prop.direction.name in ('MANYTOONE', 'MANYTOMANY'): if issubclass(model, prop.mapper.class_): reverse_prop = prop