解决使用manage.py task迁移数据库时遇到的问题:django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet

问题一

在使用manage.py 执行 makemigrations 迁移数据库的时候,遇到的问题如下

File "E:\virtual_workshop\auto-test-platform-NGrddHeT\lib\site-packages\django\apps\registry.py", line 141, in check_models_ready raise AppRegistryNotReady("Models aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet

解决办法

在manage.py中加入一行代码

django.setup()

问题二

继续执行 makegirations 发现报另一个错误

django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

解决办法

使用python manage.py makegirations进行迁移


__EOF__

本文作者cnhkzyy
本文链接https://www.cnblogs.com/my_captain/p/16201056.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   cnhkzyy  阅读(201)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2020-04-27 pytest-xdist之其他用法:dist模式、运行方式、配置文件
2020-04-27 使用pytest-xdist实现分布式APP自动化测试:基于socket
2020-04-27 使用pytest-xdist实现分布式APP自动化测试:基于SSH
点击右上角即可分享
微信分享提示