Forums

AppRegistryNotReady: Apps aren't loaded yet.

I went through the posts available for similar errors,but couldn't get rid of the error. I am using django 1.5 here I am facing error when i try to view my website here are the details :

My urls.py:

from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'webtutorials.views.home', name='home'),
    # url(r'^webtutorials/', include('webtutorials.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
    url(r'^post/', include('tutorialpost.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

My wsgi.py code:

import os
import sys

# add your project directory to the sys.path
project_home = u'/home/qchtutorials'
if project_home not in sys.path:
    sys.path.append(project_home)

# set environment variable to tell django where your settings.py is
os.environ['DJANGO_SETTINGS_MODULE'] = 'webtutorials.settings'

# serve django via WSGI
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

here is the server log :

2015-01-05 22:46:00,419 :Internal Server Error: /admin
Traceback (most recent call last):
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 87, in get_response
    response = middleware_method(request)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/middleware/common.py", line 72, in process_request
    if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 619, in is_valid_path
    resolve(path, urlconf)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 494, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 343, in resolve
    for pattern in self.url_patterns:
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 372, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "./webtutorials/urls.py", line 5, in <module>
    admin.autodiscover()
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 23, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/module_loading.py", line 67, in autodiscover_modules
    for app_config in apps.get_app_configs():
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.
2015-01-05 22:46:00,470 :Traceback (most recent call last):
2015-01-05 22:46:00,470 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-01-05 22:46:00,470 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-01-05 22:46:00,470 :  File "/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2015-01-05 22:46:00,471 :    self.error(msg, *args, **kwargs)
2015-01-05 22:46:00,471 :  File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2015-01-05 22:46:00,471 :    self._log(ERROR, msg, args, **kwargs)
2015-01-05 22:46:00,471 :  File "/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2015-01-05 22:46:00,471 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2015-01-05 22:46:00,471 :  File "/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2015-01-05 22:46:00,471 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2015-01-05 22:46:00,472 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2015-01-05 22:46:00,472 :    self.threadName = threading.current_thread().name
2015-01-05 22:46:00,472 :  File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
2015-01-05 22:46:00,472 :    return _active[_get_ident()]
2015-01-05 22:46:00,472 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-01-05 22:46:00,472 :    app_iterator = self.app(environ, start_response)
2015-01-05 22:46:00,472 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
2015-01-05 22:46:00,473 :    response = self.get_response(request)
2015-01-05 22:46:00,473 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 199, in get_response
2015-01-05 22:46:00,473 :    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2015-01-05 22:46:00,474 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
2015-01-05 22:46:00,474 :    return debug.technical_500_response(request, *exc_info)
2015-01-05 22:46:00,474 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/views/debug.py", line 91, in technical_500_response
2015-01-05 22:46:00,475 :    html = reporter.get_traceback_html()
2015-01-05 22:46:00,475 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/views/debug.py", line 350, in get_traceback_html
2015-01-05 22:46:00,476 :    return t.render(c)
2015-01-05 22:46:00,476 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 148, in render
2015-01-05 22:46:00,477 :    return self._render(context)
2015-01-05 22:46:00,477 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 142, in _render
2015-01-05 22:46:00,477 :    return self.nodelist.render(context)
2015-01-05 22:46:00,477 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 844, in render
2015-01-05 22:46:00,478 :    bit = self.render_node(node, context)
2015-01-05 22:46:00,478 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/debug.py", line 80, in render_node
2015-01-05 22:46:00,479 :    return node.render(context)
2015-01-05 22:46:00,479 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/debug.py", line 90, in render
2015-01-05 22:46:00,479 :    output = self.filter_expression.resolve(context)
2015-01-05 22:46:00,479 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 624, in resolve
2015-01-05 22:46:00,480 :    new_obj = func(obj, *arg_vals)
2015-01-05 22:46:00,480 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/defaultfilters.py", line 769, in date
2015-01-05 22:46:00,481 :    return format(value, arg)
2015-01-05 22:46:00,481 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 343, in format
2015-01-05 22:46:00,481 :    return df.format(format_string)
2015-01-05 22:46:00,482 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
2015-01-05 22:46:00,482 :    pieces.append(force_text(getattr(self, piece)()))
2015-01-05 22:46:00,482 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 268, in r
2015-01-05 22:46:00,483 :    return self.format('D, j M Y H:i:s O')
2015-01-05 22:46:00,483 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
2015-01-05 22:46:00,484 :    pieces.append(force_text(getattr(self, piece)()))
2015-01-05 22:46:00,484 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/encoding.py", line 85, in force_text
2015-01-05 22:46:00,486 :    s = six.text_type(s)
2015-01-05 22:46:00,486 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/functional.py", line 144, in __text_cast
2015-01-05 22:46:00,487 :    return func(*self.__args, **self.__kw)
2015-01-05 22:46:00,487 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 83, in ugettext
2015-01-05 22:46:00,490 :    return _trans.ugettext(message)
2015-01-05 22:46:00,490 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 325, in ugettext
2015-01-05 22:46:00,492 :    return do_translate(message, 'ugettext')
2015-01-05 22:46:00,492 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 306, in do_translate
2015-01-05 22:46:00,492 :    _default = translation(settings.LANGUAGE_CODE)
2015-01-05 22:46:00,492 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 209, in translation
2015-01-05 22:46:00,493 :    default_translation = _fetch(settings.LANGUAGE_CODE)
2015-01-05 22:46:00,493 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 189, in _fetch
2015-01-05 22:46:00,494 :    "The translation infrastructure cannot be initialized before the "
2015-01-05 22:46:00,494 :django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
2015-01-05 22:46:01,327 :Internal Server Error: /favicon.ico
Traceback (most recent call last):
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 87, in get_response
    response = middleware_method(request)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/middleware/common.py", line 72, in process_request
    if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 619, in is_valid_path
    resolve(path, urlconf)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 494, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 343, in resolve
    for pattern in self.url_patterns:
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 372, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "./webtutorials/urls.py", line 5, in <module>
    admin.autodiscover()
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 23, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/module_loading.py", line 67, in autodiscover_modules
    for app_config in apps.get_app_configs():
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.
2015-01-05 22:46:01,360 :Traceback (most recent call last):
2015-01-05 22:46:01,360 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-01-05 22:46:01,360 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-01-05 22:46:01,360 :  File "/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2015-01-05 22:46:01,360 :    self.error(msg, *args, **kwargs)
2015-01-05 22:46:01,360 :  File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2015-01-05 22:46:01,361 :    self._log(ERROR, msg, args, **kwargs)
2015-01-05 22:46:01,361 :  File "/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2015-01-05 22:46:01,361 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2015-01-05 22:46:01,361 :  File "/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2015-01-05 22:46:01,361 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2015-01-05 22:46:01,361 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2015-01-05 22:46:01,361 :    self.threadName = threading.current_thread().name
2015-01-05 22:46:01,362 :  File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
2015-01-05 22:46:01,362 :    return _active[_get_ident()]
2015-01-05 22:46:01,362 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-01-05 22:46:01,362 :    app_iterator = self.app(environ, start_response)
2015-01-05 22:46:01,362 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
2015-01-05 22:46:01,363 :    response = self.get_response(request)
2015-01-05 22:46:01,363 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 199, in get_response
2015-01-05 22:46:01,363 :    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2015-01-05 22:46:01,363 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
2015-01-05 22:46:01,364 :    return debug.technical_500_response(request, *exc_info)
2015-01-05 22:46:01,364 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/views/debug.py", line 91, in technical_500_response
2015-01-05 22:46:01,364 :    html = reporter.get_traceback_html()
2015-01-05 22:46:01,364 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/views/debug.py", line 350, in get_traceback_html
2015-01-05 22:46:01,365 :    return t.render(c)
2015-01-05 22:46:01,365 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 148, in render
2015-01-05 22:46:01,365 :    return self._render(context)
2015-01-05 22:46:01,366 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 142, in _render
2015-01-05 22:46:01,366 :    return self.nodelist.render(context)
2015-01-05 22:46:01,366 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 844, in render
2015-01-05 22:46:01,367 :    bit = self.render_node(node, context)
2015-01-05 22:46:01,367 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/debug.py", line 80, in render_node
2015-01-05 22:46:01,367 :    return node.render(context)
2015-01-05 22:46:01,367 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/debug.py", line 90, in render
2015-01-05 22:46:01,368 :    output = self.filter_expression.resolve(context)
2015-01-05 22:46:01,368 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/base.py", line 624, in resolve
2015-01-05 22:46:01,368 :    new_obj = func(obj, *arg_vals)
2015-01-05 22:46:01,368 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/template/defaultfilters.py", line 769, in date
2015-01-05 22:46:01,369 :    return format(value, arg)
2015-01-05 22:46:01,369 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 343, in format
2015-01-05 22:46:01,369 :    return df.format(format_string)
2015-01-05 22:46:01,369 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
2015-01-05 22:46:01,370 :    pieces.append(force_text(getattr(self, piece)()))
2015-01-05 22:46:01,370 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 268, in r
2015-01-05 22:46:01,371 :    return self.format('D, j M Y H:i:s O')
2015-01-05 22:46:01,371 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
2015-01-05 22:46:01,371 :    pieces.append(force_text(getattr(self, piece)()))
2015-01-05 22:46:01,371 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/encoding.py", line 85, in force_text
2015-01-05 22:46:01,371 :    s = six.text_type(s)
2015-01-05 22:46:01,372 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/functional.py", line 144, in __text_cast
2015-01-05 22:46:01,372 :    return func(*self.__args, **self.__kw)
2015-01-05 22:46:01,372 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 83, in ugettext
2015-01-05 22:46:01,372 :    return _trans.ugettext(message)
2015-01-05 22:46:01,373 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 325, in ugettext
2015-01-05 22:46:01,373 :    return do_translate(message, 'ugettext')
2015-01-05 22:46:01,373 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 306, in do_translate
2015-01-05 22:46:01,374 :    _default = translation(settings.LANGUAGE_CODE)
2015-01-05 22:46:01,374 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 209, in translation
2015-01-05 22:46:01,374 :    default_translation = _fetch(settings.LANGUAGE_CODE)
2015-01-05 22:46:01,374 :  File "/home/qchtutorials/.local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 189, in _fetch
2015-01-05 22:46:01,375 :    "The translation infrastructure cannot be initialized before the "
2015-01-05 22:46:01,375 :django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

Sometimes django gets a little confused when you use pip install --user to get a version that lives in ~/.local. Can I suggest you switch to using a virtualenv?