Displayofpatience.net runs on a shared host. It’s basically your avarage wordpress site, and the whole domain is dedicated to it. In addition to wordpress, I wanted to try if I could run a django site along with it. The first thing was to install Django.
Running stuff on a shared host can be tricky. Installing stuff can be even trickier. My first task was to install Django. Even though my host/webhotel provided Django, I wanted to use a newer version. After digging around I found a wonderful little script for creating a virtual environemnt for Python. It basically creates bin & lib (& site-packages) directories to your home directory and links them to the system-wide python. Only now when you use your “local” python you can safely install stuff to the site-packages directory, using basic “setup.py install” method. It works great and you need no additional priviledges as you install everything under your home directory. Pretty cool. Check out more information about virtual-python here.
After installing Django I was ready to try to set up a live site using it. I didn’t have any real needs for my Django site, so I decided to just hack something up, that demonstrates that I can use Django on my shared host. Displayofpatience.net runs on Apache, so I figured fcgi was the way to go. I created a .fcgi script according Django documentation and it worked out of the box. I, of course, used my own “local” python for running the fcgi script. Then I just configured .htaccess file to handle .fcgi files (all in the Django docs). Django takes care from that on, according to the project urls.py.
Here is the outcome: The awesome Lottery machine!
To spice things up a little, I also added some JQuery ajax and animations to my program. I hadn’t tried JQuery before, so that too was also a nice learning experience. I’m really happy about the outcome. Of course, the actual program is pretty useless, but now I can run my wordpress site as usually and Django applications along with it.
virtual-python seems really outdated these days, everybody uses virtualenv now.
I ran into virtualenv too, but didn’t try it because I already got virtual-python up and running and it worked for me. I thought virtualenv was more of a tool for distributing Python software and handling dependencies, but now, after a quick look at http://pypi.python.org/pypi/virtualenv, it seems it would’ve suited just as well. The page says it’s an extension of virtual-python, so you can do probaby a lot more with it. Thanks for the tip!