Django and Dreamhost, Take 2

After installing my own custom Python build, I went back and tweaked how Django ran on my Dreamhost account. My previous Django installation experience is still mostly valid. I just figured I could "upgrade" the installation to take advantage of Python 2.5 and eggs.

I installed three eggs to get Django running

# For Django
python MySQL-python

The first was mySQL support; second was for Django's built-in fcgi support; and finally Django itself.

I had a second goal in this upgrade. I wanted to partition off the "/-/" subtree (For example, for Django, instead of using the full subdomain. I had to make a couple of changes to the project's file (to handle the '-') and to the .htaccess file:

# change example for the admin application.
(r'^-/admin/', include('django.contrib.admin.urls')),

The .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^-$ /-/ [R]
RewriteRule ^-/(.*)$ /_/mysite.fcgi/-/$1 [QSA,L]
</IfModule mod_rewrite.c>

And finally, a new mysite.fcgi script found in the /_/ directory (notice that it's an underscore, not a dash):

import sys, os

# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(["method=threaded", "daemonize=false"])