Django Framework Installation

This blog will cover the following contents:

  • python in linux
  • django installation
  • django sqlite3 DB

Before we set out to use django framework for the web app development, we would like to first set up the development environment, including programming language (python), django framework as well as the database (default sqlite3, mysql, oracle, etc).

#Python#

If you are using some linux distribution (i.e, Ubuntu, Redhat, etc), then python is already pre-installed in the OS. To check whether or not python works well in your OS, you could simply type command

$ python

if the so-called python interactive interpreter shows up, then your python is working well.

To check current python version, use the following command (be careful of the capital, the linux commmands are case sensetive):

$ python -V

or

$ python --version

##Django##

There are several ways to install django. As for me, tool pip is the most straight forward way under linux (my OS is Ubuntu 14.04) environment. Obviously, we should install pip first.

$ sudo apt-get install python-pip 

When pip is installed, we could use the following command:

$ sudo pip install Django==1.4 

Here I am installing django version 1.4, feel free to use any valid version id here.

After some automatical processing, django is intalled successfully. If you want to check the django version, open a Python console and type

import django
django.VERSION

##Database##

As the “The Django Book” says that, “jango’s only hard-and-fast prerequisite is a working Python installation”. In plain words, if you have successfully implemented the above installation steps, it is already good enough to start a django-powered web projetc. In fact, django doesn’t actually require a database. If you just want to use it to serve dynamic pages that don’t hit a database, that’s perfectly fine.

But if we would like to have backend database, we should consider to set up a database.

Actually, django supports four database engines:

Where SQLite3 is the “default” BD. Here “Default” means when you installed your django, then the sqlite3 BD is set up well for you as well. In another word, no database-specific installation for sqlite3 is required, because Python ships with SQLite support. So just skip this BD setup section and ahead to the next step.

If you have other preference for the BD, please refer to the online materials here.

Now, we are already well prepared to start our first django-powred web app. Good luck!