Tuesday, November 30, 2010

Django install on Apache server

Django doc on using with wsgi server.

Learned that the base wsgi file (django.wsgi) needs to be in a legal server path. On my machine that's c:/xampp/htdocs. Otherwise get 403 error. However, the wsgi file can refer to projects anywhere on computer. The project does need to be on the path, as the doc says (and shows how to do. However, the setting of DJANGO_SETTINGS_MODULE is a little misleading. I added my project to the path (c:/xampp/django/avppng). Then DJANGO_SETTINGS_MODULE = 'settings' because it is relative to the path. The doc shows setting path to django (c:/xampp/django) and DJANGO_SETTINGS_MODULE='avppng.settings'. But this makes some relative paths in the project not work.

Python errors produce 500 errors. Look at Apache error log file c:/xampp/apache/logs/error.log to see Python errors. The doc mentioned setting LogLevel info in httpd.conf, but the default warn setting worked fine for me. Tried to use sys.stderr.write to write to log file, but didn't work.

Now I see something disturbing. I just saw an error that my administration module couldn't be found in avppng.urls. So in wsgi file I changed the path to c:/xampp/django/avppng/ and DJANGO_SETTINGS_MODULE to settings. Shut down, made a change. Then it told me a django py couldn't find avppng.urls. So I changed path back to c:/xampp/django and DJANGO_SETTINGS_MODULE to avppng.settings and it worked! How can one way work then not and visa versa?? (Slash at end of path doesn't seem to make a difference.)


No comments:

Post a Comment