django

What is django?

Django is the most-popular web-development framework written in Python.

Why do I need django?

For building our voting application!

Get django!

We don’t want to install django system wide, but rather in our local virtualenv. We’re also going to install south, a Django helper application which will make it easier for us to go back and edit our Django app later.

$ pip install django
$ pip install south

Verify It Works!

$ python
>>> import django

To quit the python prompt do:

exit()

Verify you can create a new Django app

Create a folder on the desktop called django_projects Open a new Terminal window and type the following:

mkdir django_projects
cd django_projects
django-admin.py startproject myproject

Both commands should provide no output. Once that’s finished, type the following in the Terminal window:

cd myproject
python manage.py runserver

Output should look like this:

Validating models...
0 errors found

Django version 1.2.5, using settings 'myproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

In your browser, go to http://127.0.0.1:8000/

In your Terminal window you should see something like:

[19/Mar/2011 19:19:26] "GET / HTTP/1.1" 200 2057

Back in the Terminal window where you ran python manage.py runserver, type control-c to kill the server.

Congratulations, you have run your first Django app!