私はインポートのconundrumを実行しています。新しいインポートを追加した後、私は次のエラーPython:この周期的なインポートの問題を解決する
from studentApp.models import modelStudent
File abc, line 6, in <module>
from interviewApp.models import modelInterviewQuestion
File "xyz", line 4, in <module>
from mainApp.models import modelPatient
ImportError: cannot import name modelPatient
を今これは私のファイルは mainAppです/ models.py
from studentApp.models import modelStudent #<---Added this and I get the error
のように見え、これが私の studentApp/models.pyにあるものされて取得しています私interviewApp/models.pyで今
from interviewApp.models import modelInterviewQuestion #---> has a call to modelPatient inside
from mainApp.models import modelPatient
from labApp.models import modelLabTestName #---> has a call to modelPatient inside
ファイルIは、環状インポート
の原因となっている、これを持っていますfrom mainApp.models import modelPatient #<---This is what is initiated the call
私はこれがなぜ起こっているのか理解していますが、この問題を解決する方法がわかりません。 提案がありますか?
最適な解決策は、モジュールを再編成して循環参照を破ることです。 –