Archive for the ‘Django’ Category


October 13, 2009

Download the Django:

tar xzvf Django-1.1.tar.gz

cd Django-1.1.1

sudo python install

Download the python: or add/remove software

Download the Mysql:


checking the Django is install or not

$ python
>import django
it doesn't show any message so your installation is complete.

Workings on Terminal:
Create the directory any where.
step 1:

$ mkdir django_project

$ startproject mysite  

$cd ursite

$ python runserver
Validating models...
0 errors found

Django version 1.1, using settings 'mysite.settings'
Development server is running at
Quit the server with CONTROL-C.
[13/Oct/2009 03:06:27] "GET / HTTP/1.1" 200 2053

Using default link run the django.

step 2:

create the database in mysql
$ mysql -u root -p

mysql> create database ursite;

mysql> show databases;

step 3:

changes in  ursite directory)

DATABASE_NAME = 'ursite'

$ python syncdb

Creating models:
Create the models under mysite directory

$ python startapp polls

Edit the polls/

from django.db import models

class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice = models.CharField(max_length=200)
    votes = models.IntegerField()

Edit the file again add the line mysite.polls 


$ python sql polls

You should see something similar to the following 
(the CREATE TABLE SQL statements for the polls app)

$ python syncdb

Activate the admin site

The Django admin site is not activated by default – it’s an 
opt-in thing. To activate the admin site for your installation, 
do these three things.

1.Edit the file again add the line django.contrib.admin
2.Run python syncdb
3.Edit your ursite/ 
file and uncomment the lines that reference the admin – there 
are three lines in total to uncomment.

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin

urlpatterns = patterns('',
    # Example:
    # (r'^mysite/', include('')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(,
$ python runserver 

if you already start the server just refresh the browser, In URL add
/admin/ like

1.uysite is the project name
2.polls is the application name