Revision history [back]
How to diagnose UndefinedError: 'settings' is undefined ?
I set up the site, it runs fine for a few months, then the server stops serving. I don't understand why the settings can't be found because nothing has changed on the server.
This is from the error_askbot_log:
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] mod_wsgi (pid=24567): Exception occurred processing WSGI script '/home/username/webapps/askbot/askbotSpirit/django.wsgi'.
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/Django-1.3.1-py2.7.egg/django/core/handlers/wsgi.py", line 272, in __call__
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] response = self.get_response(request)
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/Django-1.3.1-py2.7.egg/django/core/handlers/base.py", line 169, in get_response
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/Django-1.3.1-py2.7.egg/django/core/handlers/base.py", line 218, in handle_uncaught_exception
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] return callback(request, **param_dict)
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/Django-1.3.1-py2.7.egg/django/utils/decorators.py", line 93, in _wrapped_view
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] response = view_func(request, *args, **kwargs)
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/Django-1.3.1-py2.7.egg/django/views/defaults.py", line 31, in server_error
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] return http.HttpResponseServerError(t.render(Context({})))
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/coffin/template/__init__.py", line 55, in render
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] return super(Template, self).render(**context)
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/jinja2/environment.py", line 894, in render
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] return self.environment.handle_exception(exc_info, True)
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/webapps/askbot/askbot-discussion/askbot/templates/500.html", line 1, in top-level template code
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] {% extends "two_column_body.html" %}
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/webapps/askbot/askbot-discussion/askbot/templates/two_column_body.html", line 1, in top-level template code
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] {% extends "base.html" %}
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/webapps/askbot/askbot-discussion/askbot/templates/base.html", line 4, in top-level template code
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] <title>{% block title %}{% endblock %} - {{ settings.APP_TITLE|escape }}</title>
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] File "/home/username/lib/python2.7/jinja2/environment.py", line 372, in getattr
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] return getattr(obj, attribute)
[Thu May 02 12:17:45 2013] [error] [client 127.0.0.1] UndefinedError: 'settings' is undefined
I opened up a shell and the sys.path contains the correct directory of the settings.py file:
'/home/username/webapps/askbot/askbotPaleo'
I was able to access the settings from the shell:
In [9]: settings.APP_TITLE ==>> 'Sitename Q&A Forum'
I tried to insert logging into the wsqi script because that's the only way I can see the path being used.
/home/username/webapps/askbot/askbotPaleo/django.wsgi
import logging
logging.debug("current_directory: " + current_directory )
logging.debug("parent_directory: " + parent_directory )
logging.debug('DJANGO_SETTINGS_MODULE: ' + os.environ['DJANGO_SETTINGS_MODULE'] )
After I restarted the Apache server, the log files are not being updated.
How should I go about diagnosing why the settings file can't be found?