Setting up Django at Slicehost
There are a lot of nice posts out there on setting up django, and some on setting things up on slicehost, but there were some caveats and these are my notes.
First off, so far I highly recommend slicehost for the following reasons:
Most of the confusion surrounded the project name option with the PythonOption directive and the PythonPath variables. These could definitely be more clear in the stock django setup documentation.
Another thing that irritated me is specifying the root url in the url.py file. Here's what worked, finally. Note that I was probably complicating matters by not restarting apache after everything I tried. Django will look like it's "refreshed" without an Apache restart at times, but just restart after ANY code change.
Additional Notes:
- they're cheap
- they're very explicit about what you're getting in terms of hardware and performance
- they have a very slick integrated backup solution for $5 more per month. You can setup daily recurring backups and weeklies, and you can take a snapshot at any time. This ROCKs. Restore from a backup with a single click.
- Their control panel is slick, custom, and works very well.
- They offer a variety of distros. I've got both a debian and an ubuntu flavor running.
NameVirtualHost *
ServerName SERVER.DOMAIN.com
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonOption django.root /PROJECTNAME
PythonDebug On
PythonPath "['/home/USER/'] + ['/home/USER/PROJECTNAME/'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE PROJECTNAME.settings(r'^$', 'PROJECTNAME.MODEL.VIEWS.YOURVIEW'),
- After I got things more or less working, I still couldn't use the admin area. I had to make sure that Apache could write to both the directory that contained the database, and the parent database. I'm using SQLite 3 and was getting the error: django works admin can't open database
- The admin area CSS needs to be symlinked and added in the urls.py. I used the following: ln -s /PATH/TO/django-trunk/django/contrib/admin/media /home/USER/PRJECT/media