Django is a high-level Python Web framework that
encourages rapid development and clean, pragmatic design. Built by experienced
developers, it takes care of much of the hassle of Web development, so you can
focus on writing your app without needing to reinvent the wheel. It’s free and
open source.
Disclaimer: I installed this in Ubuntu 12.04 LTS, which was
in turn installed in a virtual machine.
1. Most Linux-based installations are done in the terminal, so access the terminal by
pressing Ctrl
+ Alt + T
2. Key in sudo su and your current user's password to get root access /
admin privileges.
3. For this installation we would be using pip to install Django. Pip is which is a package manager system, which is used to install and
manage software packages written in Python. To install pip:
apt-get install
python-pip
4. Next up to install, is the virtualenv
package. Virtualenv is a tool to create isolated Python environments. Installing virtualenv is a good practice, especially if you wish to
address dependencies and versions. To install virtualenv:
pip install
virtualenv
5. After virtualenv
has been installed, we create a new virtual environment, by keying in:
virtualenv ENV
6. Navigate to your ENV
folder by typing cd ENV and issuing
the command source bin/activate
- This will change the $PATH
variable, making the bin directory the first entry.
7. At this point, we install Django 1.8 (this is the current
version of Django, if you wish to install an earlier version, just replace 1.8
with whatever version you want). Install it by typing:
pip install django==1.8
pip install django==1.8
8. This was the result of the installation.
9. At this point, we can create our first Django Project named mySite by issuing the command:
django-admin.py
startproject mySite
django-admin is
Django's command-line utility for administrative tasks.
10. Typing ls would reveal that the mySite project folder has been
created.
11. Navigate to mySite
by typing cd mySite - and
ls
to see its contents, you will notice that the project folder
contains two files: the python file manage.py and another mySite
folder. manage.py is
automatically created in each Django project. manage.py is a thin wrapper
around django-admin that takes
care of several things for you before delegating to django-admin
12. Type python
manage.py migrate -- Migrations are Django’s way of propagating changes you make to your
models (adding a field, deleting a model, etc.) into your database schema.
They’re designed to be mostly automatic, but you’ll need to know when to make
migrations, when to run them, and the common problems you might run into...
its predecessor was syncdb. Although we don't have an existing
database or db schema, let's do this command.
13. To test if you have successfully
installed Django, type python manage.py runserver -- this is almost
similar to running a webserver (say for example wampserver) -- our django
project's site is accessible on our web browsers by typing http://localhost:8000 Hopefully you will be seeing
a similar screen below.
References:






