11👍
✅
ForeignKey
can take a string as an argument, i.e. models.ForeignKey('app2.App2Model')
. Of course, you should try to design your code to avoid any circular dependencies in the first place.
2👍
I agree with Cat Plus Plus about designing code to avoid circular dependencies, but should you not be able to:
try:
import app.model
except ImportError:
pass
1👍
You should still need an import statement
import app2.App2Model
But if app2 imports app1 you would get an error like you mentioned.
👤Nix
Source:stackexchange.com