admin管理员组文章数量:1400043
I'm using Visual Studio 2022 as the IDE. It has 2 projects:
- CLI - A Python Application
- Common - A Blank Django Project
The classes are created in Common > app > models.py.
app
is a Django app
CLI
is the startup project, and cli.py
is its startup file.
Common
project is referenced in CLI
.
When I Start the CLI app in debug mode, there is an error for the Question
class.
Call Stack:
Message=Apps aren't loaded yet.
Source=D:\Projects\Internal\LLRT\src\Common\app\models.py
StackTrace: File
"D:\Projects\Internal\LLRT\src\Common\app\models.py", line 4, in
<module> (Current frame)
q_id = models.IntegerField()
...<7 lines>...
correct_option_num = models.IntegerField() File "D:\Projects\Internal\LLRT\src\CLI\cli.py", line 4, in <module>
> from app.models import Option, Question, Answered_Question django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I'm using Visual Studio 2022 as the IDE. It has 2 projects:
- CLI - A Python Application
- Common - A Blank Django Project
The classes are created in Common > app > models.py.
app
is a Django app
CLI
is the startup project, and cli.py
is its startup file.
Common
project is referenced in CLI
.
When I Start the CLI app in debug mode, there is an error for the Question
class.
Call Stack:
Message=Apps aren't loaded yet.
Source=D:\Projects\Internal\LLRT\src\Common\app\models.py
StackTrace: File
"D:\Projects\Internal\LLRT\src\Common\app\models.py", line 4, in
<module> (Current frame)
q_id = models.IntegerField()
...<7 lines>...
correct_option_num = models.IntegerField() File "D:\Projects\Internal\LLRT\src\CLI\cli.py", line 4, in <module>
> from app.models import Option, Question, Answered_Question django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Share
Improve this question
edited Mar 25 at 11:18
sukesh
asked Mar 25 at 8:49
sukeshsukesh
2,41112 gold badges64 silver badges130 bronze badges
7
|
Show 2 more comments
2 Answers
Reset to default 0Try modify your cli.py to initialize Django first:
import os
import django
Also Make sure your app is properly listed in INSTALLED_APPS in settings.py
I resolved this by adding the statement django.setup()
.
It works now, but it just looks odd that the statement is in the import statements section.
Please let me know if there is a better way of doing this.
本文标签: python 3xApps aren39t loaded yetStack Overflow
版权声明:本文标题:python 3.x - Apps aren't loaded yet - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744208784a2595318.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Apps aren't loaded yet
. I have now added the call stack. Sorry, but why the down vote? The images are very clear. – sukesh Commented Mar 25 at 10:14