python - Django:模型类 __main__.Source 在 PyCharm 中加载模型时未声明显式 app_label
问题描述
我以前在 PyCharm 中的 Python shell 中加载模型之前没有错误,但现在它通过了这个错误
Traceback (most recent call last):
File "<input>", line 12, in <module>
File "C:\...\lib\site-packages\django\db\models\base.py", line 112, in __new__
raise RuntimeError(
RuntimeError: Model class __main__.Source doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
我检查了诸如this和this之类的类似问题,并遵循了建议的答案,但没有成功。有趣的是,python manage.py runserver
它不会通过任何错误和网站顺利加载。
我的环境的唯一变化是我昨天获得的 Windows 更新。
我已经为我的所有应用程序设置了应用程序名称,设置 DJANGO_SETTINGS_MODULE 并且所有导入都是绝对的。
解决方案
推荐阅读
- c# - 如果我添加随机盐,如何检查密码是否正确?
- postgresql - 具有 docker 所有权问题的 PostgreSQL
- java - 如何使用 QAF 查找元素
- junit - 如何在 Kotlin 中测试/访问伴随对象扩展函数?
- javascript - JQuery查找并更改具有数据属性的所有元素的类
- javascript - 如何缩放对于屏幕来说太大的页面?
- angularjs - 如何在使用 ng-repeat 时验证 AngularJS 表单输入
- powershell - Powershell 脚本 IE 自动登录打开另一个登录选项卡
- android - ObjectAnimator 的一部分不能与 API 级别 23 以下的 AnimationSet playTogether() 同时播放
- angular - 防止为任何子组件测试调用父路由 ngOnInit 方法