M
M
Mikhail Bolev2021-03-20 18:52:04
Django
Mikhail Bolev, 2021-03-20 18:52:04

Cyclic import in Django. How to avoid?

Good afternoon. I'm trying to connect models in Django through a One-to-Many relationship. Three models in different applications. A circular import error occurs. How to avoid this, so as not to transfer models?
Model --> Model --> Model
605619e9b6564731134883.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-03-20
@Scorpion_MB

Cyclic imports are always a signal of bad architecture. However, you can get around this by setting the ForeignKey to the model name string instead of the class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question