Circular Dependency In Models With Sqlalchemy
I'm creating a webapp which uses SQLAlchemy to access the database. I'm getting stuck with two models which are referencing to each other and ending up in an circular import which
Solution 1:
In this specific case, there is no need to import EmailModel
at all. Alter keymodel.py
to remove the import:
from pyncacoreapi.server.modelsimportApplicationModel
SQLAlchemy postpones resolving references given as strings until the last possible moment anyway, so it doesn't matter here that EmailModel
is defined yet or not. You are referring to it in the email
relationship via a string.
Post a Comment for "Circular Dependency In Models With Sqlalchemy"