在使用多个Django应用程序时如何修复“ ImportError”

阿比舍克·达尔维(Abhishek Dalvi)

我正在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。我知道这与所有三个应用程序都从彼此导入东西有关。如何解决此错误?
任何帮助表示赞赏。提前致谢。

阿比舍克·达尔维(Abhishek Dalvi)

帮助别人在未来面临同样的问题,我终于结束了创建一个新的应用程序(有HistoryModelBaseHistoryModel等),并将其导入。欢迎其他任何建议。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在运行python应用程序时,仅使用sudo的ImportError吗?

ImportError:无法导入名称应用程序

使用Alembic导入应用程序会引发ImportError

pyinstaller捆绑python应用程序后,如何修复“ ImportError:在PATH上找不到Qt5Core.dll”

ImportError:libGL.so.1:访问Heroku应用程序时出错

从Github导入:如何修复ImportError

Django 无法从应用程序文件夹导入应用程序,ImportError

Django“ /中的” ImportError“

Django allauth和ImportError

使用Twisted的pyinstaller的importError

使用CUDA的Tensorflow:ImportError

Apache Django 应用程序:ImportError:没有名为 django.core.wsgi 的模块

在Bluemix中启动Python 3应用程序时出现错误“ ImportError:没有名为请求的模块”

ImportError:在运行我的应用程序时,没有名为“ queue”的模块被cx_freeze冻结

Gunicorn ImportError:没有名为应用程序的模块

ImportError:没有名为应用程序的模块

在 Docker 上运行时 Flask 应用程序 ImportError

kivy:ImportError:没有名为应用程序的模块

散景服务器应用程序-ImportError

Django教程1-ImportError:没有名为应用程序的模块

Django 1.7应用程序配置ImportError:没有名为appname.apps的模块

无法在Python Anywhere上部署Django应用程序:ImportError:没有名为“ environ”的模块

在本地部署应用程序后,Django“ ImportError:没有名为请求的模块”

如何修复“ ImportError:无法导入名称IncompleteRead”?

如何在本地测试Heroku python应用程序?ImportError:没有名为wsgi的模块

为什么使用 python 而不是 Flask-CLI 运行 Flask 应用程序会产生 ImportError?

Django ImportError:无法导入名称

Django ImportError:ImportError:没有名为“ sheets”的模块

仅在使用docker时ImportError