gpt4 book ai didi

python - Django 1.7 部署 AppRegistryNotReady 仅在 OpenShift 上

转载 作者:太空宇宙 更新时间:2023-11-03 17:49:41 25 4
gpt4 key购买 nike

我遇到了与此类似的问题 ( Django 1.7 upgrade error: AppRegistryNotReady: Models aren't loaded yet ),但它只发生在我的 OpenShift 部署上。

我注意到它卡在管理模块上,所以我将其注释掉,但它只是转移到了其他内容。

这是我在 OpenShift 实例上遇到的错误:

Environment:

Request Method: GET
Request URL: http://my-app.rhcloud.com/

Django Version: 1.7.3
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'rest_framework',
'main',
'debug_toolbar')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
98. resolver_match = resolver.resolve(request.path_info)
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
343. for pattern in self.url_patterns:
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
372. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
366. self._urlconf_module = import_module(self.urlconf_name)
File "/opt/rh/python27/root/usr/lib64/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/app-root/runtime/repo/wsgi/myapp/myapp/urls.py" in <module>
9. url(r'^admin/', include(admin.site.urls)),
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in urls
262. return self.get_urls(), self.app_name, self.name
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in get_urls
223. self.check_dependencies()
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in check_dependencies
161. if not apps.is_installed('django.contrib.admin'):
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/apps/registry.py" in is_installed
231. self.check_apps_ready()
File "/var/lib/openshift/xxxxxxxxxxxxxxxx/python/virtenv/lib/python2.7/site-packages/django/apps/registry.py" in check_apps_ready
124. raise AppRegistryNotReady("Apps aren't loaded yet.")

Exception Type: AppRegistryNotReady at /
Exception Value: Apps aren't loaded yet.

这是我的 wigs.py 文件内容:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

为了测试 wsgi.py,我在本地使用gunicorn,看看是否能得到相同的结果,但运气不好。我对此感到非常困惑,因为我预计在使用 wsgi.py 启动方法时两者都会出现相同的错误。关于如何调试此问题或者我是否应该在 OpenShift 上查找可能触发此问题的内容有什么想法吗?

谢谢,- RB

最佳答案

对 OpenShift 还不太熟悉,我发现了这个问题。

在 OpenShift 中,不使用标准 Django wsgi.py 文件,而是替换为 wsgi/application python 脚本。我在 wsgi.py 文件中使用了新的 Django 1.7 启动服务器的方法,该方法可以正常工作,但尚未在应用程序文件中更新它。此问题已得到纠正,现在该项目正在按预期启动。

关于python - Django 1.7 部署 AppRegistryNotReady 仅在 OpenShift 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29268389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com