Ubuntu – Django Installation



Once you have completed the Ubuntu set up you can start a Django project. This article will guide you through the subversion installation so we can grab the latest version of Django code.

First we’ll need to log into our slice:

ssh -p30000 [email protected]

Remember to replace 30000 with the port number you selected in Ubuntu Set Up 1, demo with your username and the IP with your slice IP.

Once you’re logged in, let’s go ahead and grab subversion (two install methods do not use subversion, but the method I will choose does use subversion). Use the following command to install subversion:

sudo aptitude install subversion

Hit enter and watch the magic happen.

By default Django will use sqlite as its datastore but it can use other databases as well (PostgreSQL, MySQL, etc.), depending on your database of choice you may want to install the appropriate packages. This article, however, will not get into using a database at all; instead there will be separate articles for a few different database systems.

Optional Installs

There are a few packages you may wish to install at this point that are pretty commonly used with Django. To install the optional packages use this command:

sudo aptitude install python-imaging python-pythonmagick python-markdown python-textile python-docutils

You can use the show subcommand in aptitude with a given package name to show you more information about the package:

aptitude show python-imaging

You can examine the optional packages listed above and decide if you’ll want to be using them, again they’re not required but they are used frequently.

Django Download/Installation

Now that we have all of our packages, let’s get the latest version of Django…

The aptitude Way (not currently recommended)

As of this writing, v0.96 is the latest version available from aptitude. This, however, is actually quite old as the official 1.0 stable version was released in September of 2008 so I would recommend one of the next two installation options since I’ll be using the 1.0+ version of Django for the rest of the articles. Nevertheless, if you want to play it really safe this is what aptitude gave us to work with, so let’s have at it:

sudo aptitude install python-django

That’s it. Django should now be installed and useable. To make sure it got installed, run the following command:


It should respond with:

Type 'django-admin help' for usage.

Skip down to “Next Steps.”

The stable non-aptitude Way

If running the old version available in aptitude isn’t your cup-of-tea but neither is the bleeding edge svn method (demonstrated below) this method will be your best bet. We’re going to download the package for the official 1.0 stable release and install it manually. Fire up wget and follow these steps:

wget http://www.djangoproject.com/download/1.0.2/tarball/
tar xzvf Django-1.0.2-final.tar.gz
cd Django-1.0.2-final
sudo python setup.py install

That should be it, the latest and greatest stable version of Django should now be installed and ready for use. Do note that 1.0.2 is the latest as of this update. Always check the site for the latest stable version.

To make sure it got installed, run the following command:


It should respond with:

Type 'django-admin.py help' for usage.

Skip down to “Next Steps.”

The Subversion Way

If you’re all about having the latest and greatest code even if that might mean it’s got some quirks every now and again, grabbing the code from the Django subversion repository will give us just that. The Django guys claim to keep their trunk checkins pretty stable, so you may not experience any issues with this method, but it is a possibility. This is the method I will use (and assume in later articles). If you use one of the other methods, please be aware that the older version may be lacking some features.

mkdir /home/demo/sources
cd /home/demo/sources
svn co http://code.djangoproject.com/svn/django/trunk/django django

Now prepare to watch several lines of text roll up your screen. Maybe get a cup of Coffee or Tea, this will take a minute.

For this next step, we’ll need to know the python site-packages path. If you know it off hand, great! If not, simply run this command to find out:

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

It should spit out:


Now we can set up a couple of links to our Django installation. If you’ve managed to navigate away from your sources directory, please navigate back there:

cd /home/demo/sources

and then let’s run the following commands to set up the symbolic links:

sudo ln -s /home/demo/sources/django /usr/lib/python2.5/site-packages/django
sudo ln -s /home/demo/sources/django/bin/django-admin.py /usr/local/bin/django-admin.py

To make sure it got installed, run the following command:


It should respond with:

Type 'django-admin.py help' for usage.

Views: 4


What is the capital of Egypt? ( Cairo )