在使用manage.py task迁移数据库时,如何处理django.core.exceptions.AppRegistryNotReady错误?
- 内容介绍
- 文章标签
- 相关推荐
本文共计236个文字,预计阅读时间需要1分钟。
在使用 `manage.py` 执行 `makemigrations` 和迁移数据库时,遇到以下问题:
问题详情:- 文件位置:`E:\virtual_workshop\auto-test-platform-NGrddHeT\lib\site-packages\django\apps\registry.py`- 行号:141- 错误信息:`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_readyraise 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进行迁移
本文共计236个文字,预计阅读时间需要1分钟。
在使用 `manage.py` 执行 `makemigrations` 和迁移数据库时,遇到以下问题:
问题详情:- 文件位置:`E:\virtual_workshop\auto-test-platform-NGrddHeT\lib\site-packages\django\apps\registry.py`- 行号:141- 错误信息:`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_readyraise 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进行迁移

