在将Django项目从1.8升级到1.9的过程中,我们根据Django-1.9发行说明删除了所有弃用警告/错误。 但是,在项目的虚拟环境中将Django版本更新为1.9后,出现以下错误:
Traceback (most recent call last):
File "/home/django/sites/site_dev/conf/site.wsgi", line 46, in application
return get_wsgi_application()(env, start_response_with_id)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup()
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/apps.py", line 13, in <module>
from .app_name import update_language_preference
File "/home/accounts.py", line 4, in <module>
from app_name.models.core import UserAccountModel
File "/home/models/core.py", line 8, in <module>
class TimeStampedModel(models.Model):
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/db/models/base.py", line 94, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
self.check_apps_ready()
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
我们在项目中使用PostgreSQL-9.5数据库安装了许多应用程序。我们知道其中具有模型类的应用程序会导致发生此错误。 使用以下命令连接到数据库时,甚至会发生上述错误 连接光标:
django.db.connection.cursor().execute()