1

I've updated this particular app from Django 1.4 to Django 1.5 and everything's worked fine locally - I had to fix some url calls, but that was fine.Now while deploying to Webfaction and running the site through Apache + mod_wsgi I'm getting error 500s on every page I try and load.

All the config files have remained the same, only the Django libraries have changed. I've pip installed all the requirements and they load fine.

If I turn the site down to debug mode with DEBUG = True in my local settings, then everything works fine. On the error log while in debug mode, I get the following:

[Sun Mar 24 22:47:17 2013] [error] /home/user/webapps/app/htdocs/env/lib/python2.7/site-packages/django/conf/urls/defaults.py:3: DeprecationWarning: django.conf.urls.defaults is deprecated; use django.conf.urls instead
[Sun Mar 24 22:47:17 2013] [error]   DeprecationWarning)

My question is - why is this being raised as an error? [error]? Shouldn't it be at the [info] level? And could this be what's causing the 500 errors when I take the app out of debug mode?

What can I do to get the site alive again with Django 1.5? Is there a way to turn off these warnings?

I did have a look at this commit in the Django source https://github.com/django/django/commit/0d49fdb573d44794cc78c6af4761cc79c5330315 and see if I could turn off the logging in my app's local_settings file, but no luck.

This is my httpd.conf file:

ServerRoot "/home/user/webapps/app/apache2"

LoadModule dir_module        modules/mod_dir.so
LoadModule env_module        modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module       modules/mod_mime.so
LoadModule rewrite_module    modules/mod_rewrite.so
LoadModule setenvif_module   modules/mod_setenvif.so
LoadModule wsgi_module       modules/mod_wsgi.so

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/user/logs/user/access_app.log combined
ErrorLog /home/user/logs/user/error_app.log
LogLevel info
KeepAlive Off
Listen 27114
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess app processes=2 threads=12 python-path=/home/user/lib/python2.7:/home/user/webapps/app/htdocs:/home/user/webapps/app/htdocs/env/lib/python2.7/site-packages
WSGIProcessGroup app
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIScriptAlias / /home/user/webapps/app/htdocs/ag/wsgi.py

This is my wsgi.py

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ag.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
4

1 に答える 1

4

I found the solution - the [error] messages were a red herring.

In Django 1.5, when DEBUG = False in settings, then ALLOWED_HOSTS is required in the settings file. https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production

Otherwise the site will raise 500 errors - which is what I was getting.

Add the ALLOWED_HOSTS and everything's back to normal again. Simple case of RTFM.

于 2013-03-25T22:46:03.747 に答える