Django 1.7 仅在 OpenShift 上部署 AppRegistryNotReady
Django 1.7 Deployment AppRegistryNotReady only on OpenShift
我 运行 遇到了与此类似的问题 (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 脚本所取代。我有新的 Django 1.7 启动服务器的方式在 wsgi.py 文件中正常工作,但没有在应用程序文件中更新它。此问题已更正,现在项目正在按预期启动。
我 运行 遇到了与此类似的问题 (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 脚本所取代。我有新的 Django 1.7 启动服务器的方式在 wsgi.py 文件中正常工作,但没有在应用程序文件中更新它。此问题已更正,现在项目正在按预期启动。