我正在django中使用多个应用程序,并且在运行命令时遇到ImportErrormakemigrations
。
导入语句适用于以下情况:
会计/models.py
from activity.models import HistoryModel
活动/models.py
from user_management.models import Customer, Merchant, PassIssued
from accounting.models import ITMSCustomer
user_management / models.py
from accounting.models import Account, Transaction, Posting
我确定INSTALLED_APPS中列出的应用顺序很重要,并且顺序为:
'user_management',
'accounting',
'activity',
运行makemigrations
命令时出现以下错误:
File "/home/abhishek/citycash/city-server/src/cityserver/user_management/models.py", line 4, in <module>
from accounting.models import Account, Transaction, Posting
File "/home/abhishek/citycash/city-server/src/cityserver/accounting/models.py", line 17, in <module>
from activity.models import HistoryModel
File "/home/abhishek/citycash/city-server/src/cityserver/activity/models.py", line 4, in <module>
from user_management.models import Customer, Merchant, PassIssued
ImportError: cannot import name 'Customer'
我尝试更改INSTALLED_APPS中应用程序的顺序,但最终得到了不同模块的ImportError。我知道这与所有三个应用程序都从彼此导入东西有关。如何解决此错误?
任何帮助表示赞赏。提前致谢。
帮助别人在未来面临同样的问题,我终于结束了创建一个新的应用程序(有HistoryModel
,BaseHistoryModel
等),并将其导入。欢迎其他任何建议。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句