1

I am running into a similar question to this (Django 1.7 upgrade error: AppRegistryNotReady: Models aren't loaded yet) but it's only happening on my OpenShift deployment.

I was noticing it got hung-up on the admin module so I commented it out but it just moved to something else.

Here is the error I am getting on the OpenShift instance:

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.

Here is my wigs.py file contents:

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

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

To test wsgi.py I am using gunicorn locally to see if I can get the same results with no luck. I am pretty puzzled by this as I would expect the same errors on both when using the wsgi.py launch method. Any thoughts on how to debug this or if there are things I should look for on OpenShift that might trigger this issue?

Thanks, - RB

Community
  • 1
  • 1
renderbox
  • 1,595
  • 14
  • 25

1 Answers1

1

Being still a little new to OpenShift I figured out the problem.

In OpenShift, the standard Django wsgi.py file is not used and is replaced with the wsgi/application python script. I had the new Django 1.7 way of launching servers working correctly in the wsgi.py file but had not updated it in the application file. This is corrected and now the project is launching as expected.

renderbox
  • 1,595
  • 14
  • 25