我尝试使用以下方法将模型从一个应用程序导入到另一个应用程序:
from ..appName.models import className
也
from appName.models import className
但发生试图超出顶级程序包的相对导入错误。我的目的是创建一个学生管理系统。在一个应用程序中,我创建了模型,在另一个应用程序中,我尝试从该模型中检索数据,但没有成功。
├───Save_to_database
│ ├───HelpingClass
│ │ └───__pycache__
│ ├───migrations
│ │ └───__pycache__
│ └───__pycache__
├───Search
│ ├───migrations
│ │ └───__pycache__
│ └───__pycache__
├───StudentApp
│ └───__pycache__
└───templates
我想将模型从save_to_database导入到Search。
是的,我将应用程序添加到settings.py
请问我的英语
答案 0 :(得分:0)
├───Save_to_database
│ ├───HelpingClass
│ │ └───__pycache__
│ ├───migrations
│ │ └───__pycache__
│ └───__pycache__
├───Search
│ ├───migrations
│ │ └───__pycache__
│ └───__pycache__
├───StudentApp
│ └───__pycache__
└───templates
我想将模型从save_to_database导入到Search。
是的,我将应用程序添加到settings.py