Installing Django on Ubuntu 12.04
Status: Deprecated
This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
- Upgrade to Ubuntu 14.04.
- Upgrade from Ubuntu 14.04 to Ubuntu 16.04
- Migrate the server data to a supported version
Reason:
Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
Prerequisites
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 [email protected]
Remember to replace ‘2500’ with the number of port you used in the previous article.
Replace ‘demo’ with your username and ‘12.34.56.789’ 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.
django-admin
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
django-admin.py
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.