当前位置 : 主页 > 编程语言 > python >

解决使用manage.py task迁移数据库时遇到的问题:django.core.exceptions.AppRegistryNotRe

来源:互联网 收集:自由互联 发布时间:2022-07-07
问题一 在使用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 Ap

问题一

在使用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 task迁移数据库时遇到的问题:django.core.exceptions.AppRegistryNotReady:_django

解决办法

在manage.py中加入一行代码

django.setup()

解决使用manage.py task迁移数据库时遇到的问题:django.core.exceptions.AppRegistryNotReady:_python_02

问题二

继续执行 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.

解决使用manage.py task迁移数据库时遇到的问题:django.core.exceptions.AppRegistryNotReady:_perl_03

解决办法

使用​​python manage.py makegirations​​​进行迁移
解决使用manage.py task迁移数据库时遇到的问题:django.core.exceptions.AppRegistryNotReady:_perl_04


网友评论