Previous Page Next Page

Installing Django

Django can easily be installed on a Linux, Mac, or Windows server. The only prerequisite is that Python 2.3 or higher must already be installed. You can find information about installing Python at http://www.python.org/download/.

An SQL database isn't required to install Django. However, you will want to install one before you begin creating Django projects. You may need to install additional Python modules to support the database, depending on which database you choose. Django supports the MySQL, Postgre SQL, SQLite3, Oracle, and Microsoft SQL database backends. In this book, the examples will be based on the MySQL database.

At this time, you can install Django in two different ways. You can install an official release, or you can download the development version. To download the development version, you will need to install the Subversion version control system from the following website:

http://subversion.tigris.org/

The folks at the Django project are making a lot of great changes all the time, so you may want to use the development version if you want to implement the latest feature set. However, if you are developing a production website, you will want to use the released version.

Django should typically be installed in the site-packages directory of the Python installation. For example, if Python is installed in /Python25, then Django would be installed in the following location:

/Python25/Lib/site-packages/django

The following "Try It Yourself" sections take you through the steps of installing Django using each of these methods.

By the Way

Some Linux distributions now provide versions of Django integrated with their package management system. You can find a list of those third parties at the following URL:

http://www.djangoproject.com/documentation/distributions/


Try It Yourself: Install the Released Version of Django

This section describes the steps to install the released version of Django. Follow these steps to download and install the Django tarball file:

1.
Install Python 2.3 or later.

2.
Download the Django tarball from the following location:

http://www.djangoproject.com/download

3.
Use the following command to extract the tarball:

tar xzvf Django-version.tar.gz

4.
Change the directory to the Django directory created by extracting the tarball:

cd Django-version

5.
Use the following command to install Django (you need to use the sudo command on Linux so that Django gets installed as the super user):

python setup.py install
sudo python setup.py install (linux)

6.
Start a Python interpreter.

7.
Use the following command to verify that Django is installed:

import django
django.VERSION


Try It Yourself: Install the Development Version of Django

This section describes the steps to install the development version of Django. Follow these steps to download and install the Django tarball file:

1.
Install Python 2.3 or later.

2.
Install Subversion.

3.
Check out the Django trunk using the following Subversion command:

svn co http://code.djangoproject.com/svn/django/trunk django_src

4.
Either copy the django_src/django directory, or create a symbolic link to that directory in the Python site-packages directory to place Django in the Python path.

5.
Copy django/bin/django-admin.py somewhere in the system path.

By the Way

You don't need to run setup.py because it does what was done in steps 4 and 5.

6.
Start a Python interpreter.

7.
Use the following command to verify that Django is installed:

import django
django.VERSION


Previous Page Next Page