Opened 10 years ago

Closed 10 years ago

#23084 closed Bug (invalid)

uWSGI raises django.core.exceptions.AppRegistryNotReady

Reported by: kmmbvnr@… Owned by: nobody
Component: Core (Other) Version: 1.7-rc-1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I did uwsgi setup as listed here - http://smidth.ru/blog/django/django-nginx-uwsgi-supervisor/ with django 1.7 and following wsgi.ini

[uwsgi]
home=/project_path/env/
chdir=/project_path
master=True
disable-logging=True
vacuum=True
pidfile=/project_path/project.pid
max-requests=5000
socket=127.0.0.1:49001
processes=2
harakiri = 20

pythonpath=/project_path/
env=DJANGO_SETTINGS_MODULE=project.settings
module=django.core.handlers.wsgi:WSGIHandler()
touch-reload=/project_path/deploy/reload

I have to set DEBUG to False in order to see the real exception

traceback (most recent call last):
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
    response = self.get_response(request)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/core/handlers/base.py", line 199, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/core/handlers/base.py", line 243, in handle_uncaught_exception
    return callback(request, **param_dict)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/utils/decorators.py", line 105, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/views/defaults.py", line 44, in server_error
    template = loader.get_template(template_name)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/template/loader.py", line 144, in get_template
    template, origin = find_template(template_name, dirs)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/template/loader.py", line 126, in find_template
    loader = find_template_loader(loader_name)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/template/loader.py", line 98, in find_template_loader
    TemplateLoader = import_string(loader)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/template/loaders/app_directories.py", line 33, in <module>
    app_template_dirs = calculate_app_template_dirs()
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/template/loaders/app_directories.py", line 21, in calculate_app_template_dirs
    for app_config in apps.get_app_configs():
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/apps/registry.py", line 125, in get_app_configs
    self.check_ready()
  File "/srv/viewflow.io/.tox/py33/lib/python3.3/site-packages/django/apps/registry.py", line 119, in check_ready
    raise AppRegistryNotReady()
django.core.exceptions.AppRegistryNotReady

It could be fixed by adding following lines on top of django.core.handlers.wsgi.py

import django
django.setup()

Change History (2)

comment:1 by anonymous, 10 years ago

Sorry, miss the docs.

The correct solution would be specify

module=django.core.wsgi:get_wsgi_application()

comment:2 by Aymeric Augustin, 10 years ago

Resolution: invalid
Status: newclosed

Yes, that's the correct solution. May I suggest reading our official documentation rather than incorrect blog posts? ;-)

Note: See TracTickets for help on using tickets.
Back to Top