Django on Ubuntu Linux 8

posted by Jake on

My friend Josh has told me numerous times that Django is much easier to work with on Linux. Basically things are easier if you know how to do them. Whether things are easier to learn or not on Linux compared to other OS's is debatable. But, on this point anyway, it seems that Linux and Django really play well together.

My friend Josh has told me numerous times that Django is much easier to work with on Linux. Basically things are easier if you know how to do them. Whether things are easier to learn or not on Linux compared to other OS's is debatable. But, on this point anyway, it seems that Linux and Django really play well together.

First of all, when I installed Ubuntu 8 (Hardy Heron), I had 3 versions of Python already installed for me. It also came with a couple of very useful packages for python preinstalled, including PIL.

In order to get Django rockin though, we need a database. Again, I favor MySQL for reasons of familiarity. Perhaps someday I'll branch out just for fun, but for personal projects, it seems to do the job. For MySQL installation help, see this tutorial.

Now, we need to grab Django. I like to work with the latest SVN version. I create a lib directory and put stuff there.

Create a directory where you'd like django to be, and check it out from svn:

mkdir django-svn; cd django-svn
svn co http://code.djangoproject.com/svn/django/trunk/ .

Now, make Python aware of the Django packages:

cd /usr/lib/python2.5/site-packages
ln -s /home/jtsnake/dev/lib/django-svn/django django

Python also needs to know how to use the MySQL database:

sudo apt-get install python-mysqldb

If you skip this last step, you'll get this:

# if I try:
python manage.py syncdb

# I get:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

Now make it convient for django to generate projects for you by putting the admin tool in your path.

sudo emacs /etc/environment
PATH="[other dir's...]:/usr/lib/python2.5/site-packages/django/bin"

Reload env:

source /etc/environment

Now you should be ready to have all the pieces work together: Python, Django, and MySQL.

Start projects with this target:

django-admin.py startproject projectName

Happy Django'in on Linux! It's true, Josh; Django is very nice on Linux!

Another great Django/Linux setup tutorial here.

Leave a comment

blog comments powered by Disqus