Tuesday, August 5, 2014

Installing Django on Ubuntu 12.04

Installing Django on Ubuntu 12.04


As a prerequisite, we are assuming that you have gone through the article on how to set up your droplet and now you are ready for a Django project. If not, you can find the article here
First, we will log into droplet.
ssh –p 25000 demo@
Remember to replace ‘2500’ with the number of port you used in the previous article.
Replace ‘demo’ with your username and ‘’ with your droplet IP.
Django uses sqlite by default, but, you can use other databases like MySQL, PostgreSQL etc as well. In this article, we will not be using any database.

Optional installations

There are a number of optional packages that can be used with Django. Run the following command to install the optional packages.
 sudo aptitude install python-imaging python-pythonmagick python-markdown python-textile python-docutils
If you want more information about the package then use ‘show’ subcommand with the respective package name.
 aptitude show python-imaging
These packages are optional and frequently used. So it’s up to you if you want to use them with Django or not.

Installing Django

Now, we will download the Django unto our servers.

Installing Django with Aptitude:

To date, this is not the recommended way of installing Django as it comes with an older version. However, if you still want to follow this method, you can use this command
 sudo aptitude install python-django
Once it has download, you can check that Django is installed and working.
The prompt will show the line below, followed by a long set of options.
 Usage: django-admin subcommand [options] [args]
Move on to the Next Steps section at the end of the article.

Installing Django without Aptitude:

If you don’t want to use aptitude, then this is your best bet for installing Django. In this method, we will download the official stable release and install it manually.
 wget https://www.djangoproject.com/download/1.4/tarball/
tar xzvf index.html
cd Django-1.4
sudo python setup.py install
You can use this command to check that Django is installed and working
You should get below response, and it will be followed by a long set of options.
Usage: django-admin subcommand [options] [args]

Installing Django from the Git Repository

If you are looking for the latest release of Django that supports all major features, then download the program through git.
Before you start, you need to download git:
apt-get install git-core
Once it downloads, you can install Django:
 git clone https://github.com/django/django.git
Then more on the next steps.

Next Steps

By now, we are done with the installation of latest, stable release of Django. Now, we are ready to install a web server that will actually serve the Django app. There are a number of methods for installing web server but we will be focusing on mod_wsgi.

No comments:

Post a Comment