SlideShare a Scribd company logo
The Django Web Framework


Simon Willison
http://simonwillison.net/



EuroPython, 3rd July 2006
Web development on
Journalism deadlines
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
... in three days
Characteristics
  Clean URLs
  Loosely coupled components
  Designer-friendly templates
  Less code


  Really fast development
Components
URL dispatching
http://www.example.com/poll/5/



 What code shall we
    execute?
(r'^$', 'views.index'),
(r'^hello/$', ‘views.hello'),
(r'^poll/(d+)/$', ‘views.poll'),
Views
def index(request):
    s = "Hello, World"
    return HttpResponse(s)
def index(request):
  name = request.GET['name']
  s = "Hi, " + escape(name)
  return HttpResponse(s)
Models
...
(r'^poll/(d+)/$', 'views.poll'),
...
...
(r'^poll/(d+)/$', 'views.poll'),
...

def poll(request, poll_id):
  poll = Poll.objects.get(
    pk=poll_id
  )
  return HttpResponse(
    'Question: ' + poll.question
  )
class Poll(Model):
  question = CharField(maxlength=200)
  pub_date = DateTimeField()


class Choice(Model):
  poll = ForeignKey(Poll)
  choice = CharField(maxlength=200)
  votes = IntegerField()
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_polls" ("id"),
    "choice" varchar(200) NOT NULL,
    "votes" integer NOT NULL
);
COMMIT;
p = Poll(
  question = "What's up?",
  pub_date = datetime.now()
)
p.save()

p.choice_set.create(
  choice = "Some choice",
  votes = 0
)
>>> p.id
1

>>> p.question
"What's up?"

>>> p.choice_set.all()
[<Choice: Some choice>]
>>> Poll.objects.count()
7

>>> Poll.objects.filter(
  pub_date__year = 2006,
  pub_date__month = 5
)
["What's up?"]

>>> Poll.objects.all()[0:2]
["What's up", "Like Django?"]
Templates
Gluing strings together
     gets old fast
c = Context({
    'today': datetime.date.today(),
    'edibles': ['pear', 'apple', 'orange']
})
<h1>Hello World!</h1>

<p>Today is {{ today|date:"jS F, Y" }}</p>

{% if edibles %}
<ul>
  {% for fruit in edibles %}
     <li>{{ fruit }}</li>
  {% endfor %}
</ul>
{% endif %}
<h1>Hello World!</h1>

<p>Today is 2nd July, 2006</p>

<ul>
   <li>pear</li>
   <li>apple</li>
   <li>orange</li>
</ul>
def hello(request):
  return render_to_response('hello.html',{
     'today': datetime.date.today(),
     'edibles': ['pear', 'apple', 'orange']
  })
Common headers and
    footers?
Template inheritance
base.html
<html>
<head>
<title>
  {% block title %}{% endblock %}
</title>
</head>
<body>
{% block main %}{% endblock %}
<div id=”footer”>
{% block footer %}(c) 2006{% endblock %}
</div>
</body>
</html>
home.html

{% extends “base.html” %}
{% block title %}Homepage{% endblock %}

{% block main %}
Main page contents goes here.
{% endblock %}
combined
<html>
<head>
<title>
  Homepage
</title>
</head>
<body>
Main page contents goes here.
<div id=”footer”>
(c) 2006
</div>
</body>
</html>
Loosely coupled
Icing
The Django Web Framework (EuroPython 2006)
Bengali         Japanese
 Czech             Dutch
  Welsh         Norwegian
 Danish           Brazilian
German          Romanian
 Greek            Russian
 English           Slovak
 Spanish         Slovenian
 French           Serbian
 Galician         Swedish
Hebrew           Ukrainian
Icelandic   Simplified Chinese
  Italian   Traditional Chinese
msgid "Usernames cannot contain the '@' character."
msgstr "Ім'я не може містити '@' символ"
Forms are boring
1. Display form

2. Validate submitted data

3. If errors, redisplay with:

  3.1. Contextual error messages

  3.2. Correct fields pre-filled

4. ... do something useful!
Model validation rules
+ the Manipulator API
 do all of this for you
The admin package
 does even more
The Django Web Framework (EuroPython 2006)
No time to talk about...

  Generic views
  Data object serialisation
  Syndication framework
  Middleware
  Authentication and authorisation
Success stories
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
170+ public Django-powered sites

 http://code.djangoproject.com/wiki/DjangoPoweredSites


90+ contributors

1900+ mailing list subscribers (and 900+ on
the development list)

And the Journal-World have convinced three
new people to go and work in Kansas
Find out more
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
www.djangoproject.com

More Related Content

What's hot (20)

jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
Paul Irish
 
Yql hacku iitd_2012
Yql hacku iitd_2012
Anshu Prateek
 
Hacking up location aware apps
Hacking up location aware apps
Anshu Prateek
 
20111014 mu me_j_querymobile
20111014 mu me_j_querymobile
Erik Duval
 
Coming to Terms with GraphQL
Coming to Terms with GraphQL
Bruce Williams
 
Mume JQueryMobile Intro
Mume JQueryMobile Intro
Gonzalo Parra
 
Cheap frontend tricks
Cheap frontend tricks
ambiescent
 
One Size Fits All
One Size Fits All
Claudio Meinberg
 
USC Yahoo! BOSS, YAP and YQL Overview
USC Yahoo! BOSS, YAP and YQL Overview
Jonathan LeBlanc
 
Introduction to Jquery
Introduction to Jquery
Amzad Hossain
 
Simplifying Code: Monster to Elegant in 5 Steps
Simplifying Code: Monster to Elegant in 5 Steps
tutec
 
You're Doing It Wrong
You're Doing It Wrong
bostonrb
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
Engine Yard
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9
Jack Franklin
 
Sql inyection
Sql inyection
Alonso Cerdas
 
Hi5 Opensocial Code Lab Presentation
Hi5 Opensocial Code Lab Presentation
plindner
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5
성일 한
 
Django の認証処理実装パターン / Django Authentication Patterns
Django の認証処理実装パターン / Django Authentication Patterns
Masashi Shibata
 
Pagination in PHP
Pagination in PHP
Vineet Kumar Saini
 
PHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
Paul Irish
 
Hacking up location aware apps
Hacking up location aware apps
Anshu Prateek
 
20111014 mu me_j_querymobile
20111014 mu me_j_querymobile
Erik Duval
 
Coming to Terms with GraphQL
Coming to Terms with GraphQL
Bruce Williams
 
Mume JQueryMobile Intro
Mume JQueryMobile Intro
Gonzalo Parra
 
Cheap frontend tricks
Cheap frontend tricks
ambiescent
 
USC Yahoo! BOSS, YAP and YQL Overview
USC Yahoo! BOSS, YAP and YQL Overview
Jonathan LeBlanc
 
Introduction to Jquery
Introduction to Jquery
Amzad Hossain
 
Simplifying Code: Monster to Elegant in 5 Steps
Simplifying Code: Monster to Elegant in 5 Steps
tutec
 
You're Doing It Wrong
You're Doing It Wrong
bostonrb
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
Engine Yard
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9
Jack Franklin
 
Hi5 Opensocial Code Lab Presentation
Hi5 Opensocial Code Lab Presentation
plindner
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5
성일 한
 
Django の認証処理実装パターン / Django Authentication Patterns
Django の認証処理実装パターン / Django Authentication Patterns
Masashi Shibata
 
PHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 

Similar to The Django Web Framework (EuroPython 2006) (20)

The Django Web Application Framework
The Django Web Application Framework
Simon Willison
 
E3 appspresso hands on lab
E3 appspresso hands on lab
NAVER D2
 
E2 appspresso hands on lab
E2 appspresso hands on lab
NAVER D2
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
Dave Artz
 
CCCDjango2010.pdf
CCCDjango2010.pdf
jayarao21
 
The Best (and Worst) of Django
The Best (and Worst) of Django
Jacob Kaplan-Moss
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 
Jquery fundamentals
Jquery fundamentals
Salvatore Fazio
 
Introduction to Html5
Introduction to Html5
www.netgains.org
 
112 portfpres.pdf
112 portfpres.pdf
sash236
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
huhu
huhu
Dung Trương
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Python & Django TTT
Python & Django TTT
kevinvw
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
Using Apache Solr
Using Apache Solr
pittaya
 
Computational Social Science, Lecture 09: Data Wrangling
Computational Social Science, Lecture 09: Data Wrangling
jakehofman
 
Google App Engine with Gaelyk
Google App Engine with Gaelyk
Choong Ping Teo
 
The Django Web Application Framework
The Django Web Application Framework
Simon Willison
 
E3 appspresso hands on lab
E3 appspresso hands on lab
NAVER D2
 
E2 appspresso hands on lab
E2 appspresso hands on lab
NAVER D2
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
Dave Artz
 
CCCDjango2010.pdf
CCCDjango2010.pdf
jayarao21
 
The Best (and Worst) of Django
The Best (and Worst) of Django
Jacob Kaplan-Moss
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 
112 portfpres.pdf
112 portfpres.pdf
sash236
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Python & Django TTT
Python & Django TTT
kevinvw
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
Using Apache Solr
Using Apache Solr
pittaya
 
Computational Social Science, Lecture 09: Data Wrangling
Computational Social Science, Lecture 09: Data Wrangling
jakehofman
 
Google App Engine with Gaelyk
Google App Engine with Gaelyk
Choong Ping Teo
 
Ad

More from Simon Willison (20)

How Lanyrd does Geo
How Lanyrd does Geo
Simon Willison
 
Building Lanyrd
Building Lanyrd
Simon Willison
 
How we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graph
Simon Willison
 
Web Services for Fun and Profit
Web Services for Fun and Profit
Simon Willison
 
Tricks & challenges developing a large Django application
Tricks & challenges developing a large Django application
Simon Willison
 
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Simon Willison
 
How Lanyrd uses Twitter
How Lanyrd uses Twitter
Simon Willison
 
ScaleFail
ScaleFail
Simon Willison
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
Simon Willison
 
Building crowdsourcing applications
Building crowdsourcing applications
Simon Willison
 
Evented I/O based web servers, explained using bunnies
Evented I/O based web servers, explained using bunnies
Simon Willison
 
Crowdsourcing with Django
Crowdsourcing with Django
Simon Willison
 
Django Heresies
Django Heresies
Simon Willison
 
Class-based views with Django
Class-based views with Django
Simon Willison
 
Web App Security Horror Stories
Web App Security Horror Stories
Simon Willison
 
Web Security Horror Stories
Web Security Horror Stories
Simon Willison
 
When Zeppelins Ruled The Earth
When Zeppelins Ruled The Earth
Simon Willison
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
I love Zeppelins, and you should too
I love Zeppelins, and you should too
Simon Willison
 
OpenID at Open Tech 2008
OpenID at Open Tech 2008
Simon Willison
 
How we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graph
Simon Willison
 
Web Services for Fun and Profit
Web Services for Fun and Profit
Simon Willison
 
Tricks & challenges developing a large Django application
Tricks & challenges developing a large Django application
Simon Willison
 
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Simon Willison
 
How Lanyrd uses Twitter
How Lanyrd uses Twitter
Simon Willison
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
Simon Willison
 
Building crowdsourcing applications
Building crowdsourcing applications
Simon Willison
 
Evented I/O based web servers, explained using bunnies
Evented I/O based web servers, explained using bunnies
Simon Willison
 
Crowdsourcing with Django
Crowdsourcing with Django
Simon Willison
 
Class-based views with Django
Class-based views with Django
Simon Willison
 
Web App Security Horror Stories
Web App Security Horror Stories
Simon Willison
 
Web Security Horror Stories
Web Security Horror Stories
Simon Willison
 
When Zeppelins Ruled The Earth
When Zeppelins Ruled The Earth
Simon Willison
 
When Ajax Attacks! Web application security fundamentals
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
I love Zeppelins, and you should too
I love Zeppelins, and you should too
Simon Willison
 
OpenID at Open Tech 2008
OpenID at Open Tech 2008
Simon Willison
 
Ad

Recently uploaded (20)

Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Dancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptx
Elliott Richmond
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0
RodrigoMori7
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Dancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptx
Elliott Richmond
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0
RodrigoMori7
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 

The Django Web Framework (EuroPython 2006)