Django Setup Notes

I’ve been messing with Django recently, and wanted to record a few setup notes for future reference. It might be of use for anyone else who’s experimenting with it to have some setup notes in one place.

I’m playing with a small project as a learning exercise which I hope to announce in the next few months and coming from the configuration-heavy world of J2EE using Spring and Hibernate, Django is a breath of fresh air. Django’s version of MVC is very nicely put together, and the framework comes complete with just about every feature that you might attempt to write yourself such as generic views, cache plugins, and URL rewriting. The ORM is fantastic, and Django 1.1’s addition of aggregation and “greedy” fetching of foreign key relationships using select_related() is a pleasure (though be sure to filter the fields you need or you can end up with unnecessary database queries).

Django setup with MySQL on Ubuntu –

  1. Download Django
  2. Download the latest version of MySQLDB for Python
  3. Before you build / install the above you’ll probably need the python dev libs and the mysql dev libs:
    1. sudo apt-get install python-all-dev
    2. sudo apt-get install libmysqlclient15-dev
  4. Install MysqlDB and Django, start reading through the django book.

(As an aside, when you’re missing a library on ubunutu is there any easy way to figure out what apt package it resides in? I would like to be able to figure it out without resorting to just asking google and finding that some other poor soul has spent a few hours looking for the answer.)

I’d recommend mod_wsgi over mod_python. In completely unscientific performance tests mod_wsgi seemed to play nicer with the other children. Here’s a good install document for Django and mod_wsgi.

An alternate to these notes is this step-by-step guite to django on ubuntu, including memcached, Nginx, and a whole host of other nonsense you probably don’t need to do some tinkering.

Leave a Reply

Your email address will not be published. Required fields are marked *