Django! (Problems...)

software development

#1

I’ve followed the Wiki to the smallest detail… gone step by step. Everything seems to work (SQL conns, Paths, etc) until I try and actually visit a URL.

One of two things happens. Either the connection times out, or I get a 500 error.

I’ve tried making the little test-app to test FastCGI - also a no go, which leads me to believe that’s the culprit.

I’ve been scouring the net for anything and everything… including having to kill fcgi processes. It appears as though the process isn’t even getting started.

So basically… has anyone else been having trouble with installing Django? I’ve got FastCGI enabled… downloaded all the appropriate software… configured the appropriate settings… and still nothing…

Thanks.


#2

I got django working on my dreamhost account recently.

Check your http server log files ($HOME/logs/yourdomain.com/http) - they should be informative, and let us know what the error message is. One issue I ran into is that the database driver doesn’t expect to be used from multiple threads (as you get with Dreamhost’s FCGI), so you have to apply a patch to the django db driver. I found the patch at http://code.djangoproject.com/ticket/463

The patch was for mysql and I was using sqlite3 so I manually applied similar changes to the file django/score/db/backends/sqlite3.py and it seemed to work.


#3

Thanks for the reply.

I’ll try the patch, though I don’t think that’s the problem I’m encountering this moment (though that’s not to say it won’t trip me up later).

I attempted to run a plain-Jane fcgi test file… same error as before.

Here she blows (note: the file shown here is django.fcgi, but it’s the same whether or not it’s this file or something else):

Connection reset by peer: FastCGI: comm with server “/home/username/mydomain.com/django.fcgi” aborted: read failed


#4

Here’s my setup. (Using the account name XYZ as an example)

directories
/home/XYZ/src/python - my python source tree. this directory goes into my PYTHONPATH
/home/XYZ/src/django_src - django sources. this also goes into PYTHONPATH
/home/XYZ/bin,lib,include - anything I had to compile or install that wasn’t on dreamhost

I installed python 2.4 and sqlite3 from sources. When building anything from source I set --prefix=/home/XYZ
My top level python package is APP, so for example settings.py is located in /home/XYZ/src/python/APP/settings.py.

in /home/XYZ/.bash_profile:
export PATH=$HOME/bin:$HOME/src/django_src/django/bin:$PATH
export PYTHONPATH=$HOME/src/django_src:$HOME/src/python
export DJANGO_SETTINGS_MODULE=APP.settings

in /home/XYZ/mydomain.com/.htaccess:
set the rewrite rules as documented in the wiki. For example,
RewriteRule ^(.*)$ django.fcgi/$1 [L]

The contents of /home/XYZ/mydomain.com/django.fcgi:
#!/usr/bin/env python
import sys
sys.path.append(’/home/XYZ/src/django_src’)
sys.path.append(’/home/XYZ/src/python’)
from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os
os.environ[‘DJANGO_SETTINGS_MODULE’] = 'APP.settings’
WSGIServer(WSGIHandler()).run()

fcgi.py is in the same directory as django.fcgi.
Double-check the permissions to make sure that all files are readable by the XYZ user, and that the database, and any other files or directories that are updated by the web application are writable by the XYZ user.