SlideShare ist ein Scribd-Unternehmen logo
1 von 38
The Django Web Application
        Framework


                     zhixiong.hong
                       2009.3.26
Outline
 Overview
 Architecture
 Modules
 Example
 Links
Outline
 Overview
 Architecture
 Example
 Modules
 Links
Web Application Framework
 Define
  “A software framework that is designed to support the development of
     dynamic website, Web applications and Web services”(from wikipedia)
 The ideal framework
   Clean URLs
   Loosely coupled components
   Designer-friendly templates
   As little code as possible
   Really fast development
Web Application Framework(cont..)
 Ruby
  Ruby on Rails (famous, beauty)
 Python
  Django, TurboGears, Pylons, Zope, Quixote,web2py(simple)
 PHP
  CakePHP, CodeIgniter, PRADO, ThinkPHP,QeePHP (poor performance)
 Others
  Apache, J2EE, .NET...(complex)
Web Application Framework(cont..)
Comparsion
What a Django
 “Django is a high-level Python web framework that
  encourages rapid development and clean, pragmatic
  design.”
 Primary Focus
   Dynamic and database driven website
   Content based websites
Django History
 Named after famous Guitarist “Django Reinhardt”
 Developed by Adrian Holovaty & Jacob Kaplan-moss
 Open sourced in 2005
 1.0 Version released Sep.3 2008, now 1.1 Beta
Why Use Django
 Lets you divide code modules into logical groups to make it flexible
  to change
   MVC design pattern (MVT)
 Provides auto generated web admin to ease the website
  administration
 Provides pre-packaged API for common user tasks
 Provides you template system to define HTML template for your
  web pages to avoid code duplication
   DRY Principle
 Allows you to define what URL be for a given Function
   Loosely Coupled Principle
 Allows you to separate business logic from the HTML
   Separation of concerns
 Everything is in python (schema/settings)
Outline
 Overview
 Architecture
 Modules
 Example
 Links
Django as an MVC Design Pattern
  MVT Architecture:
   Models
    Describes your data structure/database schema
   Views
     Controls what a user sees
   Templates
     How a user sees it
   Controller
     The Django Framework
     URL dispatcher
Architecture Diagram

                    Brower



         Template              URL dispatcher



                     View



                     Model



                    DataBase
Model

                   Brower



        Template              URL dispatcher



                    View



                    Model



                   DataBase
Model Overview
SQL Free
ORM
Relations
API
Model

  class Category(models.Model):
       name = models.CharField(max_length=200)
       slug = models.SlugField(unique=True)



  class Entry(models.Model):
       title = models.CharField(max_length=200)
       slug = models.SlugField(unique=True)
       body = models.TextField()
       data = models.DateTimeField(default=datetime.now)
       categories = models.ManyToManyField(Category)


  python manage.py syncdb
Model API
  >>> category = Category(slug='django', name='Django')
  >>> category.save()
  >>> print category.name
  u'Django'

  >>> categories = Category.objects.all()
  >>> categories = Category.objects.filter(slug='django')
  >>> categories
  [<Category: Category object>]

  >>> entry = Entry(slug='welcome', title='Welcome', body='')
  >>> entry.save()
  >>> entry.categories.add( category[0] )
  >>> print entry.categories.all()
  [<Category: Category object>]
View

                  Brower



       Template              URL dispatcher



                   View



                   Model



                  DataBase
View

  def entry_list(request):
      entries = Ebtry.objects.all()[:5]
      return render_to_response('list.html', {'entries': entries})



  def entry_details(request, slug):
       entry = get_object_or_404(Entry, slug = slug)
       return render_to_response('details.html', {'entry': entry})
Template

                      Brower



           Template              URL dispatcher



                       View



                       Model



                      DataBase
Template Syntax
 {{ variables }}, {% tags %}, filters               (list.html)

  <html>
      <head>
      <title>My Blog</title>
      </head>
      <body>
      {% for entry in entries %}
      <h1>{{ entry.title|upper }}</h1>
      {{ entry.body }}<br/>
      Published {{ entry.data|date:quot;d F Yquot; }},
      <a href=”{{ entry.get_absolute_url }}”>link</a>.
      {% endfor %}
      </body>
  </html>
Tag and Filter
 Build in Filters and Tags
 Custom tag and filter libraries
   Put logic in tags
  {% load comments %}
  <h1>{{ entry.title|upper }}</h1>
  {{ entry.body }}<br/>
  Published {{ entry.data|date:quot;d F Yquot; }},
  <a href=”{{ entry.get_absolute_url }}”>link</a>.
  <h3>评论: </h3>
  {% get_comment_list for entry as comment_list %}
  {% for comment in comment_list %}
       {{ comment.content }}
  {% endfor %}
Template Inheritance
 base.html                      index.html
  <html>
      <head>
      <title>
                                {% extend “base.html” %}
            {% block title %}
                                {% block title %}
            {% endblock %}
                                     Main page
      </title>
                                {% endblock %}
      </head>
                                {% block body %}
      <body>
                                     Content
            {% block body %}
                                {% endblock %}
            {% endblock %}
      </body>
  </html>
URL Dispatcher

                   Brower



        Template              URL Dispatcher



                    View



                    Model



                   DataBase
URL Dispatcher

  urlpatterns = patterns('',
  #http://jianghu.leyubox.com/articles/
  ((r'^articles/$', ‘article.views.index'), )

  #http://jianghu.leyubox.com/articles/2003/
  (r'^articles/(?P<year>d{4})/$', ‘article.views.year_archive'),

  # http://jianghu.leyubox.com/articles/2003/ 12/
  (r'^articles/(?P<year>d{4})/(?P<month>d{2})/$',
  'article.views.month_archive'),

  # http://jianghu.leyubox.com/articles/2003/ 12/3
  (r'^articles/(?P<year>d{4})/(?P<month>d{2})/(?P<day>d+)/$', 'article..
  views.article_detail'), )
Outline
 Overview
 Architecture
 Modules
 Example
 Links
Modules
 Form
 Adminstration interface
 Custom Middleware
 Caching
 Signals
 Comments system
 More...
Modules:Form

  class ContactForm(forms.Form):
       subject = forms.CharField(max_length=100)
       message = forms.CharField(widget=forms.Textarea)
       sender = forms.EmailField()
       cc_myself = forms.BooleanField(required=False)



  <form action=quot;/contact/quot; method=quot;POSTquot;>
       {{ form.as_table}}
       <input type=quot;submitquot; value=quot;Submitquot; />
  </form>
Modules:Adminstration interface
Modules: Custom Middleware
     chain of processes


request                                                         response
           Common       Session     Authentication     Profile
          Middleware   Middleware    Middleware      Middleware
Modules: Caching


   Memcached     Database   Filesystem     Local-memory        Dummy


                            BaseCache



                                                          template caching
                                   Per-View Caching
      Per-Site Caching
Modules:More...
 Sessions
 Authentication system
 Internationalization and localization
 Syndication feeds(RSS/Atom)
 E-mail(sending)
 Pagination
 Signals
Outline
 Overview
 Architecture
 Modules
 Example
 Links
Example
 django_admin startproject leyubbs
 modify setting.py
   set database options
   append admin app: django.contrib.admin
 python manager.py syncdb
 python manager.py runserver
 modify urls.py, append /admin path
Example(cont...)
 python manager.py startapp article
 add a model
 python manager.py syncdb
 explore admin page
 inset a record in adminstration interface
 add a veiw function
 add a url
Outline
 Overview
 Architecture
 Modules
 Example
 Links
Links: Who Use
Links: Resource
 http://www.djangoproject.com/
  For more information (Documentation,Download and News)

 http://www.djangobook.com/
  A Good book to learn Django

 http://www.djangopluggables.com
  A lot of Django Pluggables available online Explore at

 http://www.pinaxproject.com/
  Community Development
Thanks (Q&A)

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To DjangoJay Graves
 
Intro to Web Development Using Python and Django
Intro to Web Development Using Python and DjangoIntro to Web Development Using Python and Django
Intro to Web Development Using Python and DjangoChariza Pladin
 
Building an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkBuilding an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkChristopher Foresman
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and DjangoMichael Pirnat
 
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...Edureka!
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django frameworkKnoldus Inc.
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Edureka!
 
Django Rest Framework - Building a Web API
Django Rest Framework - Building a Web APIDjango Rest Framework - Building a Web API
Django Rest Framework - Building a Web APIMarcos Pereira
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture IntroductionHaiqi Chen
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS DirectivesEyal Vardi
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django IntroductionGanga Ram
 
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...Edureka!
 

Was ist angesagt? (20)

Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To Django
 
Python/Django Training
Python/Django TrainingPython/Django Training
Python/Django Training
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
 
Intro to Web Development Using Python and Django
Intro to Web Development Using Python and DjangoIntro to Web Development Using Python and Django
Intro to Web Development Using Python and Django
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Building an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkBuilding an API with Django and Django REST Framework
Building an API with Django and Django REST Framework
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
django
djangodjango
django
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Django Rest Framework - Building a Web API
Django Rest Framework - Building a Web APIDjango Rest Framework - Building a Web API
Django Rest Framework - Building a Web API
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
 

Andere mochten auch

The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application FrameworkSimon Willison
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django ArchitectureRami Sayar
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Django - Software Architecture and Design
Django - Software Architecture and DesignDjango - Software Architecture and Design
Django - Software Architecture and DesignMarcello Romanelli
 
Django Overview
Django OverviewDjango Overview
Django OverviewBrian Tol
 
Django & Python Case Studies
  Django & Python Case Studies  Django & Python Case Studies
Django & Python Case StudiesLeo TechnoSoft
 
Functional Requirements of mobile application
Functional Requirements of mobile application Functional Requirements of mobile application
Functional Requirements of mobile application Semiu Ayobami Akanmu
 
software testing strategies
software testing strategiessoftware testing strategies
software testing strategiesHemanth Gajula
 
Online shopping portal: Software Project Plan
Online shopping portal: Software Project PlanOnline shopping portal: Software Project Plan
Online shopping portal: Software Project Planpiyushree nagrale
 
Sample Mobile Apps PRD
Sample Mobile Apps PRDSample Mobile Apps PRD
Sample Mobile Apps PRDUjjwal Trivedi
 
Mobile Application Design & Development
Mobile Application Design & DevelopmentMobile Application Design & Development
Mobile Application Design & DevelopmentRonnie Liew
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSHannes Hapke
 
Online shopping report-6 month project
Online shopping report-6 month projectOnline shopping report-6 month project
Online shopping report-6 month projectGinne yoffe
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 

Andere mochten auch (20)

Django introduction
Django introductionDjango introduction
Django introduction
 
The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application Framework
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django Architecture
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Django - Software Architecture and Design
Django - Software Architecture and DesignDjango - Software Architecture and Design
Django - Software Architecture and Design
 
Django Overview
Django OverviewDjango Overview
Django Overview
 
Django & Python Case Studies
  Django & Python Case Studies  Django & Python Case Studies
Django & Python Case Studies
 
Django In Depth
Django In DepthDjango In Depth
Django In Depth
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
Functional Requirements of mobile application
Functional Requirements of mobile application Functional Requirements of mobile application
Functional Requirements of mobile application
 
software testing strategies
software testing strategiessoftware testing strategies
software testing strategies
 
Online shopping portal: Software Project Plan
Online shopping portal: Software Project PlanOnline shopping portal: Software Project Plan
Online shopping portal: Software Project Plan
 
Sample Mobile Apps PRD
Sample Mobile Apps PRDSample Mobile Apps PRD
Sample Mobile Apps PRD
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Mobile Application Design & Development
Mobile Application Design & DevelopmentMobile Application Design & Development
Mobile Application Design & Development
 
Django Best Practices
Django Best PracticesDjango Best Practices
Django Best Practices
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
 
Online shopping report-6 month project
Online shopping report-6 month projectOnline shopping report-6 month project
Online shopping report-6 month project
 
Rapport de stage du fin d'étude
Rapport de stage du fin d'étudeRapport de stage du fin d'étude
Rapport de stage du fin d'étude
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 

Ähnlich wie The Django Web Application Framework 2

Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVCAlan Dean
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introductionTomi Juhola
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Eric Palakovich Carr
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsJohn Brunswick
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_HourDilip Patel
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigWake Liu
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030Kevin Wu
 
WRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptx
WRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptxWRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptx
WRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptxsalemsg
 
Real-World AJAX with ASP.NET
Real-World AJAX with ASP.NETReal-World AJAX with ASP.NET
Real-World AJAX with ASP.NETgoodfriday
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Guillaume Laforge
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplicationolegmmiller
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 

Ähnlich wie The Django Web Application Framework 2 (20)

Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # Twig
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
 
WRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptx
WRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptxWRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptx
WRStmlDSQUmUrZpQ0tFJ4Q_a36bc57fe1a24dd8bc5ba549736e406f_C2-Week2.pptx
 
Real-World AJAX with ASP.NET
Real-World AJAX with ASP.NETReal-World AJAX with ASP.NET
Real-World AJAX with ASP.NET
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 

Kürzlich hochgeladen

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Kürzlich hochgeladen (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

The Django Web Application Framework 2

  • 1. The Django Web Application Framework zhixiong.hong 2009.3.26
  • 2. Outline  Overview  Architecture  Modules  Example  Links
  • 3. Outline  Overview  Architecture  Example  Modules  Links
  • 4. Web Application Framework  Define “A software framework that is designed to support the development of dynamic website, Web applications and Web services”(from wikipedia)  The ideal framework  Clean URLs  Loosely coupled components  Designer-friendly templates  As little code as possible  Really fast development
  • 5. Web Application Framework(cont..)  Ruby Ruby on Rails (famous, beauty)  Python Django, TurboGears, Pylons, Zope, Quixote,web2py(simple)  PHP CakePHP, CodeIgniter, PRADO, ThinkPHP,QeePHP (poor performance)  Others Apache, J2EE, .NET...(complex)
  • 7. What a Django  “Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design.”  Primary Focus  Dynamic and database driven website  Content based websites
  • 8. Django History  Named after famous Guitarist “Django Reinhardt”  Developed by Adrian Holovaty & Jacob Kaplan-moss  Open sourced in 2005  1.0 Version released Sep.3 2008, now 1.1 Beta
  • 9. Why Use Django  Lets you divide code modules into logical groups to make it flexible to change MVC design pattern (MVT)  Provides auto generated web admin to ease the website administration  Provides pre-packaged API for common user tasks  Provides you template system to define HTML template for your web pages to avoid code duplication DRY Principle  Allows you to define what URL be for a given Function Loosely Coupled Principle  Allows you to separate business logic from the HTML Separation of concerns  Everything is in python (schema/settings)
  • 10. Outline  Overview  Architecture  Modules  Example  Links
  • 11. Django as an MVC Design Pattern MVT Architecture:  Models Describes your data structure/database schema  Views Controls what a user sees  Templates How a user sees it  Controller The Django Framework URL dispatcher
  • 12. Architecture Diagram Brower Template URL dispatcher View Model DataBase
  • 13. Model Brower Template URL dispatcher View Model DataBase
  • 15. Model class Category(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(unique=True) class Entry(models.Model): title = models.CharField(max_length=200) slug = models.SlugField(unique=True) body = models.TextField() data = models.DateTimeField(default=datetime.now) categories = models.ManyToManyField(Category) python manage.py syncdb
  • 16. Model API >>> category = Category(slug='django', name='Django') >>> category.save() >>> print category.name u'Django' >>> categories = Category.objects.all() >>> categories = Category.objects.filter(slug='django') >>> categories [<Category: Category object>] >>> entry = Entry(slug='welcome', title='Welcome', body='') >>> entry.save() >>> entry.categories.add( category[0] ) >>> print entry.categories.all() [<Category: Category object>]
  • 17. View Brower Template URL dispatcher View Model DataBase
  • 18. View def entry_list(request): entries = Ebtry.objects.all()[:5] return render_to_response('list.html', {'entries': entries}) def entry_details(request, slug): entry = get_object_or_404(Entry, slug = slug) return render_to_response('details.html', {'entry': entry})
  • 19. Template Brower Template URL dispatcher View Model DataBase
  • 20. Template Syntax  {{ variables }}, {% tags %}, filters (list.html) <html> <head> <title>My Blog</title> </head> <body> {% for entry in entries %} <h1>{{ entry.title|upper }}</h1> {{ entry.body }}<br/> Published {{ entry.data|date:quot;d F Yquot; }}, <a href=”{{ entry.get_absolute_url }}”>link</a>. {% endfor %} </body> </html>
  • 21. Tag and Filter  Build in Filters and Tags  Custom tag and filter libraries Put logic in tags {% load comments %} <h1>{{ entry.title|upper }}</h1> {{ entry.body }}<br/> Published {{ entry.data|date:quot;d F Yquot; }}, <a href=”{{ entry.get_absolute_url }}”>link</a>. <h3>评论: </h3> {% get_comment_list for entry as comment_list %} {% for comment in comment_list %} {{ comment.content }} {% endfor %}
  • 22. Template Inheritance base.html index.html <html> <head> <title> {% extend “base.html” %} {% block title %} {% block title %} {% endblock %} Main page </title> {% endblock %} </head> {% block body %} <body> Content {% block body %} {% endblock %} {% endblock %} </body> </html>
  • 23. URL Dispatcher Brower Template URL Dispatcher View Model DataBase
  • 24. URL Dispatcher urlpatterns = patterns('', #http://jianghu.leyubox.com/articles/ ((r'^articles/$', ‘article.views.index'), ) #http://jianghu.leyubox.com/articles/2003/ (r'^articles/(?P<year>d{4})/$', ‘article.views.year_archive'), # http://jianghu.leyubox.com/articles/2003/ 12/ (r'^articles/(?P<year>d{4})/(?P<month>d{2})/$', 'article.views.month_archive'), # http://jianghu.leyubox.com/articles/2003/ 12/3 (r'^articles/(?P<year>d{4})/(?P<month>d{2})/(?P<day>d+)/$', 'article.. views.article_detail'), )
  • 25. Outline  Overview  Architecture  Modules  Example  Links
  • 26. Modules  Form  Adminstration interface  Custom Middleware  Caching  Signals  Comments system  More...
  • 27. Modules:Form class ContactForm(forms.Form): subject = forms.CharField(max_length=100) message = forms.CharField(widget=forms.Textarea) sender = forms.EmailField() cc_myself = forms.BooleanField(required=False) <form action=quot;/contact/quot; method=quot;POSTquot;> {{ form.as_table}} <input type=quot;submitquot; value=quot;Submitquot; /> </form>
  • 29. Modules: Custom Middleware chain of processes request response Common Session Authentication Profile Middleware Middleware Middleware Middleware
  • 30. Modules: Caching Memcached Database Filesystem Local-memory Dummy BaseCache template caching Per-View Caching Per-Site Caching
  • 31. Modules:More...  Sessions  Authentication system  Internationalization and localization  Syndication feeds(RSS/Atom)  E-mail(sending)  Pagination  Signals
  • 32. Outline  Overview  Architecture  Modules  Example  Links
  • 33. Example  django_admin startproject leyubbs  modify setting.py  set database options  append admin app: django.contrib.admin  python manager.py syncdb  python manager.py runserver  modify urls.py, append /admin path
  • 34. Example(cont...)  python manager.py startapp article  add a model  python manager.py syncdb  explore admin page  inset a record in adminstration interface  add a veiw function  add a url
  • 35. Outline  Overview  Architecture  Modules  Example  Links
  • 37. Links: Resource  http://www.djangoproject.com/ For more information (Documentation,Download and News)  http://www.djangobook.com/ A Good book to learn Django  http://www.djangopluggables.com A lot of Django Pluggables available online Explore at  http://www.pinaxproject.com/ Community Development