Introduction To
What is Django ?
●   Django is a high-level Python Web framework
    that encourages rapid development and clean,
    pragmatic design.


●   Django makes it easier to build better Web apps
    more quickly and with less code.


●   The Web framework with perfectionists with
    deadlines.
Django Requirements
●   Python (2.3+)
●   PostgreSQL / MySQL / SQLite / ...
●   Apache + mod_python /mod_wsgi / FastCGI / ...
Features
●   Object- Relation        ●   Unicode support
    Mapper                  ●   Cache framework
●   Templating Language     ●   Testing framework
●   Automatic Language      ●   Great docs (650+pages
●   Elegant ursl            ●   Friendly community
●   MVC architecture
More Features
●   Jython support           ●   Send emails easily
●   Nice support for forms   ●   Built -in site maps
●   Built in dcv server      ●   Built-in RSS/ATOM
●   Solid security           ●   ”Signal” hooks
    emphasis
Components
●   Models – Django ORM
●   Templates - Django Templates Engine
●   Views – Python function , Request in , Request
    out
●   URL Patterns – Regular expression based
Lets Build a Project
$django-admin.py startproject myproject

myproject/
    __init__.py
    manage.py
    settings.py
    urls.py
Run Server

$ ./manage.py runserver
Validating models...
0 errors found.

Django   version    1.2-pre,   using    settings
'myproject.settings'
Development     server     is     running     at
http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Introduction to Django
Typical Application Workflow
●   Create application
●   Create models.py and admin.py
●   'python manage.py syncdb'
●   Create urls.py and views.py
Creating models

$python manage.py startapp polls
polls/ __init__.py
      models.py
      tests.py
      views.py
Edit polls/model.py
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()
Continue ...
●   $python manage.py sql polls
    BEGIN;

    CREATE TABLE "polls_poll" (

        "id" serial NOT NULL PRIMARY KEY,

        "question" varchar(200) NOT NULL,

        "pub_date" timestamp with time zone NOT NULL   );

    CREATE TABLE "polls_choice" (

        "id" serial NOT NULL PRIMARY KEY,

        "poll_id" integer NOT NULL REFERENCES "polls_poll" ("id"),

        "choice" varchar(200) NOT NULL,

        "votes" integer NOT NULL);

    COMMIT;

●   $python manage.py syncdb              // update database
Playing With API
>>> from mysite.polls.models import Poll, Choice # Import the model classes we
just wrote.
# No polls are in the system yet.
>>> Poll.objects.all()
[ ]
# Create a new Poll.
>>> import datetime
>>> p = Poll(question="What's up?", pub_date=datetime.datetime.now())
# Save the object into the database. You have to call save() explicitly.
>>> p.save()
# Access database columns via Python attributes.
>>> p.question
"What's up?"
>>> p.pub_date
datetime.datetime(2007, 7, 15, 12, 00, 53)
# Change values by changing the attributes, then calling save().
>>> p.pub_date = datetime.datetime(2007, 4, 1, 0, 0)
>>> p.save()
# objects.all() displays all the polls in the database.
>>> Poll.objects.all()
[<Poll: Poll object>]
Activate the admin site
Edit the file /mysite/urls.py
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
    # Example:
    # (r'^mysite/', include('mysite.foo.urls')),
    # 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(admin.site.urls)),
)
Start the development server
$python manage.py runserver
Now, open a Web browser and go to "/admin/" on your local domain --
e.g., http://127.0.0.1:8000/admin/. You should see the admin's login
screen:
Docs , Books ,People
●   docs.djangoproject.com
●   djangobook.com
●   djangosnippets.com
●   djangopeople.net
●   djangosites.org
THANKS 


Submited by :-
Jagdeep Singh Malhi
Website :-www.jagdeepmalhi.blogspot.com

More Related Content

PDF
The Django Book - Chapter 5: Models
PPTX
Tango with django
PDF
How to write easy-to-test JavaScript
PPTX
Angular 2 Architecture
PPTX
Template syntax in Angular 2.0
PDF
Developing iOS REST Applications
PPTX
Angular 1.x vs. Angular 2.x
PDF
Speed is a feature - Django Meetup Buenos Aires June 2014
The Django Book - Chapter 5: Models
Tango with django
How to write easy-to-test JavaScript
Angular 2 Architecture
Template syntax in Angular 2.0
Developing iOS REST Applications
Angular 1.x vs. Angular 2.x
Speed is a feature - Django Meetup Buenos Aires June 2014

What's hot (20)

KEY
Making Django and NoSQL Play Nice
PDF
Improving the performance of Odoo deployments
PDF
X-Code UI testing architecture and tools
PPTX
Web development with django - Basics Presentation
PPTX
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
PDF
정오의 데이트 for iOS 코드 정리
PDF
Practical Google App Engine Applications In Py
PPTX
AngularJS - $http & $resource Services
PPTX
Angular 2 - Ahead of-time Compilation
PDF
Javascript Test Automation Workshop (21.08.2014)
PDF
jQuery in 15 minutes
PDF
Django tricks (2)
PPT
Django
PDF
Do something in 5 with gas 9-copy between databases with oauth2
PDF
The Odoo JS Framework
PPTX
Http Communication in Angular 2.0
KEY
Sprout core and performance
PPTX
Goa tutorial
PDF
Jqeury ajax plugins
PDF
Javascript call ObjC
Making Django and NoSQL Play Nice
Improving the performance of Odoo deployments
X-Code UI testing architecture and tools
Web development with django - Basics Presentation
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
정오의 데이트 for iOS 코드 정리
Practical Google App Engine Applications In Py
AngularJS - $http & $resource Services
Angular 2 - Ahead of-time Compilation
Javascript Test Automation Workshop (21.08.2014)
jQuery in 15 minutes
Django tricks (2)
Django
Do something in 5 with gas 9-copy between databases with oauth2
The Odoo JS Framework
Http Communication in Angular 2.0
Sprout core and performance
Goa tutorial
Jqeury ajax plugins
Javascript call ObjC
Ad

Viewers also liked (7)

PDF
PPT
Transnet Freight Rail - Safety elements 2011
PDF
Railway Safet Regulator - 2011 back to school report back
PDF
Associative Classification: Synopsis
PPT
Transnet Freight RAil - Safety communications 2011
PDF
Ra feb 2010 mr
PDF
Railways Africa June 2010
Transnet Freight Rail - Safety elements 2011
Railway Safet Regulator - 2011 back to school report back
Associative Classification: Synopsis
Transnet Freight RAil - Safety communications 2011
Ra feb 2010 mr
Railways Africa June 2010
Ad

Similar to Introduction to Django (20)

ODP
Introduction to Django
PDF
Python & Django TTT
PDF
Intro to Web Development Using Python and Django
PDF
A Basic Django Introduction
PPTX
Introduction and features to Django.pptx
DOCX
Akash rajguru project report sem v
PDF
An Introduction to Django Web Framework
PDF
ODP
dJango
PDF
a hands on guide to django
PDF
django
PDF
GDG Addis - An Introduction to Django and App Engine
PPTX
Django - Python MVC Framework
PPTX
Django framework
PPTX
Django Framework Interview Guide - Part 1
PDF
Introduction to Python and Django
PPTX
Django course
PDF
django_introduction20141030
PDF
Django Overview
PDF
The Django Web Application Framework
Introduction to Django
Python & Django TTT
Intro to Web Development Using Python and Django
A Basic Django Introduction
Introduction and features to Django.pptx
Akash rajguru project report sem v
An Introduction to Django Web Framework
dJango
a hands on guide to django
django
GDG Addis - An Introduction to Django and App Engine
Django - Python MVC Framework
Django framework
Django Framework Interview Guide - Part 1
Introduction to Python and Django
Django course
django_introduction20141030
Django Overview
The Django Web Application Framework

Recently uploaded (20)

PDF
4 layer Arch & Reference Arch of IoT.pdf
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
PDF
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PDF
The AI Revolution in Customer Service - 2025
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
PDF
Altius execution marketplace concept.pdf
PDF
Examining Bias in AI Generated News Content.pdf
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
PDF
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
CEH Module 2 Footprinting CEH V13, concepts
PPTX
Internet of Everything -Basic concepts details
4 layer Arch & Reference Arch of IoT.pdf
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
SGT Report The Beast Plan and Cyberphysical Systems of Control
The AI Revolution in Customer Service - 2025
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
Altius execution marketplace concept.pdf
Examining Bias in AI Generated News Content.pdf
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
A symptom-driven medical diagnosis support model based on machine learning te...
Lung cancer patients survival prediction using outlier detection and optimize...
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
Build Real-Time ML Apps with Python, Feast & NoSQL
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
NewMind AI Weekly Chronicles – August ’25 Week IV
CEH Module 2 Footprinting CEH V13, concepts
Internet of Everything -Basic concepts details

Introduction to Django

  • 2. What is Django ? ● Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. ● Django makes it easier to build better Web apps more quickly and with less code. ● The Web framework with perfectionists with deadlines.
  • 3. Django Requirements ● Python (2.3+) ● PostgreSQL / MySQL / SQLite / ... ● Apache + mod_python /mod_wsgi / FastCGI / ...
  • 4. Features ● Object- Relation ● Unicode support Mapper ● Cache framework ● Templating Language ● Testing framework ● Automatic Language ● Great docs (650+pages ● Elegant ursl ● Friendly community ● MVC architecture
  • 5. More Features ● Jython support ● Send emails easily ● Nice support for forms ● Built -in site maps ● Built in dcv server ● Built-in RSS/ATOM ● Solid security ● ”Signal” hooks emphasis
  • 6. Components ● Models – Django ORM ● Templates - Django Templates Engine ● Views – Python function , Request in , Request out ● URL Patterns – Regular expression based
  • 7. Lets Build a Project $django-admin.py startproject myproject myproject/ __init__.py manage.py settings.py urls.py
  • 8. Run Server $ ./manage.py runserver Validating models... 0 errors found. Django version 1.2-pre, using settings 'myproject.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
  • 10. Typical Application Workflow ● Create application ● Create models.py and admin.py ● 'python manage.py syncdb' ● Create urls.py and views.py
  • 11. Creating models $python manage.py startapp polls polls/ __init__.py models.py tests.py views.py
  • 12. Edit polls/model.py 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()
  • 13. Continue ... ● $python manage.py sql polls BEGIN; CREATE TABLE "polls_poll" ( "id" serial NOT NULL PRIMARY KEY, "question" varchar(200) NOT NULL, "pub_date" timestamp with time zone NOT NULL ); CREATE TABLE "polls_choice" ( "id" serial NOT NULL PRIMARY KEY, "poll_id" integer NOT NULL REFERENCES "polls_poll" ("id"), "choice" varchar(200) NOT NULL, "votes" integer NOT NULL); COMMIT; ● $python manage.py syncdb // update database
  • 14. Playing With API >>> from mysite.polls.models import Poll, Choice # Import the model classes we just wrote. # No polls are in the system yet. >>> Poll.objects.all() [ ] # Create a new Poll. >>> import datetime >>> p = Poll(question="What's up?", pub_date=datetime.datetime.now()) # Save the object into the database. You have to call save() explicitly. >>> p.save() # Access database columns via Python attributes. >>> p.question "What's up?" >>> p.pub_date datetime.datetime(2007, 7, 15, 12, 00, 53) # Change values by changing the attributes, then calling save(). >>> p.pub_date = datetime.datetime(2007, 4, 1, 0, 0) >>> p.save() # objects.all() displays all the polls in the database. >>> Poll.objects.all() [<Poll: Poll object>]
  • 15. Activate the admin site Edit the file /mysite/urls.py from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^mysite/', include('mysite.foo.urls')), # 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(admin.site.urls)), )
  • 16. Start the development server $python manage.py runserver Now, open a Web browser and go to "/admin/" on your local domain -- e.g., http://127.0.0.1:8000/admin/. You should see the admin's login screen:
  • 17. Docs , Books ,People ● docs.djangoproject.com ● djangobook.com ● djangosnippets.com ● djangopeople.net ● djangosites.org
  • 18. THANKS  Submited by :- Jagdeep Singh Malhi Website :-www.jagdeepmalhi.blogspot.com