SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
What is Django?
        Features
     References




Introducing Django

      Horst Gutmann


   September 30, 2007




                        1 / 34
What is Django?
                                Features
                             References


Disclaimer




   I’m not of the developers of Django but merely a user who likes
   what he’s seen. My experience is limited to small sites that can be
   comfortably run on a shared host such as Dreamhost.
   And I want to apologize for the noise my laptop is probably going
   to make during the presentation ;-)




                                                                         2 / 34
What is Django?
                                                   General
                                        Features
                                                   What do you need?
                                     References


What is Django?

                  Django is a high-level Python Web framework that
              encourages rapid development and clean, pragmatic
              design.
   [1]
              Model-View-Controller for the Web
              Written in Python
              Explicit instead of implicit
              Developed for the Lawrence Journal-World1 newspaper in
              Kansas


         1
             http://www2.ljworld.com/
                                                                       3 / 34
What is Django?
                                    General
                         Features
                                    What do you need?
                      References


What is an MVC web framework?




  Abstraction




                                                        5 / 34
What is Django?
                                        General
                             Features
                                        What do you need?
                          References


Abstract HTTP




     Do we really want to manually parse HTTP requests?
     Frameworks should automate things like header creation
     Allow easy cookie handling




                                                              6 / 34
What is Django?
                                               General
                                    Features
                                               What do you need?
                                 References


Abstract database calls



   Page . o b j e c t s . g e t ( i d =10)
   instead of
   SELECT ∗ FROM page WHERE i d =10;
   Not to mention keeping it backend independent and mapping the
   resultset to objects in the used programming language.




                                                                   8 / 34
What is Django?
                                                  General
                                       Features
                                                  What do you need?
                                    References


Dispatch URLs



        URLs or URL patterns should be mapped to functions or
        objects
        ... that then create the output.

   u r l p a t t e r n s += p a t t e r n s ( ’ ’ ,
           u r l ( ’ ˆ$ ’ , ’ v i e w s . i n d e x ’ ) ,
   )




                                                                      10 / 34
What is Django?
                                          General
                               Features
                                          What do you need?
                            References


MVC or MVT?


  Django uses a little bit different naming for the
  Model-View-Controller pattern.
       Models abstract the used data by defining classes for them
              and storing them in relational tables.
        Views take the job of the controllers in MVC and basically
              define, what the user gets to see. Functions, not
              classes here.
    Templates define how the users see the view




                                                                     11 / 34
What is Django?
                                           General
                                Features
                                           What do you need?
                             References


Projects and Applications



        Project A project is for example your whole website. Here
                you store your central configuration and general
                templates and images (just as an example).
   Applications are where you store the actual functionality. For
                example a weblog would be an application. An
                account system would be an application ...
   Applications are a simple way to share common functionality
   between various projects.




                                                                    12 / 34
What is Django?
                                              General
                                   Features
                                              What do you need?
                                References


Easy start




          Python2 (ideally 2.5 since sqlite is bundled with it)
          a text editor
   This is all you need to start developing with Django since Django
   comes with its own lightweight webserver to make it very easy for
   everyone to start playing around with it.




     2
         http://www.python.org
                                                                       13 / 34
What is Django?
                                      General
                           Features
                                      What do you need?
                        References


Yet flexible




                                              SQLite
      FastCGI
                                              MySQL
      mod python
                                              PostgreSQL
      mod wsgi
                                              Oracle in preparation




                                                                      14 / 34
What is Django?    Contributed apps
                               Features   The Template Language
                            References    Simple Form Processing


Main features (for me)



      A good collection of contributed applications
          Administration interface
          Authentication system
          Comments system
          ...
      Template language focused on inheritance
      Simple form processing
      No magic




                                                                   15 / 34
What is Django?    Contributed apps
                            Features   The Template Language
                         References    Simple Form Processing


Administration interface I




                                                                16 / 34
What is Django?    Contributed apps
                               Features   The Template Language
                            References    Simple Form Processing


Administration interface II




       Available in django.contrib.admin
       Configured through model definitions
       Configurable using templates (possible per model),
       JavaScripts and CSS
       Currently a rewrite using newforms is in the pipe.




                                                                   17 / 34
What is Django?    Contributed apps
                                   Features   The Template Language
                                References    Simple Form Processing



Authentication system3




          django.contrib.auth
          Just hook it in, and you get a login screen
          ... and usergroups
          ... and custom permissions




     3
         http://www.djangoproject.com/documentation/authentication/
                                                                       18 / 34
What is Django?    Contributed apps
                                   Features   The Template Language
                                References    Simple Form Processing



django-registration5



          By James Bennett4
          Offers all you really need:
              Simple registration form
              E-mail activation
          Works with django.contrib.auth




     4
         http://www.b-list.org/about/
     5
         http://code.google.com/p/django-registration/
                                                                       19 / 34
What is Django?    Contributed apps
                                 Features   The Template Language
                              References    Simple Form Processing


The Template Language



      Very restrictive
           ... to keep application logic within the View and the Model
           Don’t let templates change the state of your site!
           If you want to have complex code in your templates, you have
           to define your own template tags in Python.
      Inheritance between templates
      You have to pass variables explicitly to the template from the
      view




                                                                          20 / 34
What is Django?    Contributed apps
                                 Features   The Template Language
                              References    Simple Form Processing


Template Basics

     Variables Rendered with
              {{ variable_name }}



        Tags allow you to do more sophisticated stuff while
             keeping the actual Python code out of the template:
              {% template_tag %}



              Even conditional blocks are realized as tags.
       Filters allow you to manipulate the output of a variable:
              {{ variable|filter }}



              E.g.: Escaping strings, converting from Markdown to
              HTML, ...

                                                                     22 / 34
What is Django?    Contributed apps
                                Features   The Template Language
                             References    Simple Form Processing



Template Inheritance6
  The core of inheritance are blocks the templates.
  base.html                            index.html
  <html>                                    {% extends ’base.html’ %}
    <body>                                  {% block title %}
      <h1>                                      Index page
        {% block title %}                   {% endblock %}
        {% endblock %}                      {% block content %}
      </h1>                                     ...
      <div id=quot;contentquot;>                    {% endblock %}
        {% block content %}
        {% endblock %}
      </div>
    </body>
  </html>
     6
       http://www.djangoproject.com/documentation/templates/
   #template-inheritance
                                                                        24 / 34
What is Django?    Contributed apps
                                  Features   The Template Language
                               References    Simple Form Processing



newforms7


         ”newforms” because there was something before that ... let’s
         ignore the only form processing for now ;-)
         Easy way to define forms
         ... to render them
         ... and to validate their data
         Easily combinable with models (as you will see in the
         demoapp)




    7
        http://www.djangoproject.com/documentation/newforms/
                                                                        25 / 34
What is Django?    Contributed apps
                                     Features   The Template Language
                                  References    Simple Form Processing


Form definition



   from d j a n g o import newforms a s f o r m s
   c l a s s CommentForm ( m o d e l s . Form ) :
           a u t h o r = form . C h a r F i e l d ( ’ Your name ’ )
           e m a i l = form . E m a i l F i e l d ( ’ Your e−m a i l )
           body = form . C h a r F i e l d ( ’ Comment ’ ,
                   w i d g e t=f o r m s . T e x t a r e a ( ) )




                                                                         27 / 34
What is Django?          Contributed apps
                                                 Features         The Template Language
                                              References          Simple Form Processing


Form output




   {{ form . a s p }}
  Results in:
  <p> a b e l f o r=” i d a u t h o r ”>Your name :</ l a b e l>
     <l
      <i n p u t i d=” i d a u t h o r ” t y p e=” t e x t ” name=” a u t h o r ” m a x l e n g t h=” 100 ” /></p>
  <p> a b e l f o r=” i d e m a i l ”>Your e−m a i l :</ l a b e l>
     <l
      <i n p u t i d=” i d e m a i l ” t y p e=” t e x t ” name=” e m a i l ” m a x l e n g t h=” 75 ” />  </p>
  <p> a b e l f o r=” i d b o d y ”>Comment :</ l a b e l>
     <l
      <t e x t a r e a i d=” i d b o d y ” rows=” 10 ” c o l s=” 40 ” name=” body ”> t e x t a r e a>
                                                                                               </             </p>




                                                                                                                     29 / 34
What is Django?    Contributed apps
                                      Features   The Template Language
                                   References    Simple Form Processing


Form data validation


   Everything is done in Python, so it’s easily re-usable.
   c l a s s CommentForm ( f o r m s . Form ) :

     # ...

     def c l e a n e m a i l ( s e l f ) :
       e m a i l = s e l f . c l e a n e d d a t a [ ” e m a i l ” ] . s p l i t ( ”@” ) [ 1 ]
       i f e m a i l i n [ ” h o t m a i l . com” , ” yahoo . com” ] :
          r a i s e V a l i d a t i o n E r r o r , ” Get a GMail a c c o u n t ! ”




                                                                                                 31 / 34
What is Django?
                         Features
                      References




“Django project site.” [Online]. Available:
http://www.djangoproject.com/




                                              32 / 34
What is Django?
                                Features
                             References


Thank you




  for your attention.
  Any last question?




                                           33 / 34
What is Django?
                               Features
                            References


Want to get some action?




   If you liked what you saw, we could meet somewhere and build a
   little website together :-)




                                                                    34 / 34

Contenu connexe

Similaire à Introducing Django

Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersRosario Renga
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoAhmed Salama
 
* DJANGO - The Python Framework - Low Kian Seong, Developer
    * DJANGO - The Python Framework - Low Kian Seong, Developer    * DJANGO - The Python Framework - Low Kian Seong, Developer
* DJANGO - The Python Framework - Low Kian Seong, DeveloperLinuxmalaysia Malaysia
 
Why Django is The Go-To Framework For Python.pdf
Why Django is The Go-To Framework For Python.pdfWhy Django is The Go-To Framework For Python.pdf
Why Django is The Go-To Framework For Python.pdfMindfire LLC
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| EdurekaEdureka!
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docxfantabulous2024
 
Concepts and applications of Django.pptx
Concepts and applications of Django.pptxConcepts and applications of Django.pptx
Concepts and applications of Django.pptxsushmitjivtode4
 
Django Workflow and Architecture
Django Workflow and ArchitectureDjango Workflow and Architecture
Django Workflow and ArchitectureAndolasoft Inc
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django frameworkKnoldus Inc.
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in DjangoLakshman Prasad
 
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdfDjango Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdfSudhanshiBakre1
 

Similaire à Introducing Django (20)

Django Introdcution
Django IntrodcutionDjango Introdcution
Django Introdcution
 
Django
Django Django
Django
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
 
Django
DjangoDjango
Django
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
* DJANGO - The Python Framework - Low Kian Seong, Developer
    * DJANGO - The Python Framework - Low Kian Seong, Developer    * DJANGO - The Python Framework - Low Kian Seong, Developer
* DJANGO - The Python Framework - Low Kian Seong, Developer
 
Why Django is The Go-To Framework For Python.pdf
Why Django is The Go-To Framework For Python.pdfWhy Django is The Go-To Framework For Python.pdf
Why Django is The Go-To Framework For Python.pdf
 
Django
DjangoDjango
Django
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| Edureka
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
Django PPT.pptx
Django PPT.pptxDjango PPT.pptx
Django PPT.pptx
 
Concepts and applications of Django.pptx
Concepts and applications of Django.pptxConcepts and applications of Django.pptx
Concepts and applications of Django.pptx
 
Django Workflow and Architecture
Django Workflow and ArchitectureDjango Workflow and Architecture
Django Workflow and Architecture
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
 
Django
DjangoDjango
Django
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
Basic Python Django
Basic Python DjangoBasic Python Django
Basic Python Django
 
Dojango
DojangoDojango
Dojango
 
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdfDjango Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
 

Dernier

Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon investment
 
Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000
Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000
Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000dlhescort
 
JAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
JAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLJAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
JAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceDamini Dixit
 
Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting
 
Business Model Canvas (BMC)- A new venture concept
Business Model Canvas (BMC)-  A new venture conceptBusiness Model Canvas (BMC)-  A new venture concept
Business Model Canvas (BMC)- A new venture conceptP&CO
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentationuneakwhite
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...rajveerescorts2022
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876dlhescort
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...lizamodels9
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPanhandleOilandGas
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Anamikakaur10
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1kcpayne
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 

Dernier (20)

Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business Growth
 
Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000
Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000
Call Girls In Majnu Ka Tilla 959961~3876 Shot 2000 Night 8000
 
JAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
JAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLJAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
JAYNAGAR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Business Model Canvas (BMC)- A new venture concept
Business Model Canvas (BMC)-  A new venture conceptBusiness Model Canvas (BMC)-  A new venture concept
Business Model Canvas (BMC)- A new venture concept
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation Final
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 

Introducing Django

  • 1. What is Django? Features References Introducing Django Horst Gutmann September 30, 2007 1 / 34
  • 2. What is Django? Features References Disclaimer I’m not of the developers of Django but merely a user who likes what he’s seen. My experience is limited to small sites that can be comfortably run on a shared host such as Dreamhost. And I want to apologize for the noise my laptop is probably going to make during the presentation ;-) 2 / 34
  • 3. What is Django? General Features What do you need? References What is Django? Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. [1] Model-View-Controller for the Web Written in Python Explicit instead of implicit Developed for the Lawrence Journal-World1 newspaper in Kansas 1 http://www2.ljworld.com/ 3 / 34
  • 4. What is Django? General Features What do you need? References What is an MVC web framework? Abstraction 5 / 34
  • 5. What is Django? General Features What do you need? References Abstract HTTP Do we really want to manually parse HTTP requests? Frameworks should automate things like header creation Allow easy cookie handling 6 / 34
  • 6. What is Django? General Features What do you need? References Abstract database calls Page . o b j e c t s . g e t ( i d =10) instead of SELECT ∗ FROM page WHERE i d =10; Not to mention keeping it backend independent and mapping the resultset to objects in the used programming language. 8 / 34
  • 7. What is Django? General Features What do you need? References Dispatch URLs URLs or URL patterns should be mapped to functions or objects ... that then create the output. u r l p a t t e r n s += p a t t e r n s ( ’ ’ , u r l ( ’ ˆ$ ’ , ’ v i e w s . i n d e x ’ ) , ) 10 / 34
  • 8. What is Django? General Features What do you need? References MVC or MVT? Django uses a little bit different naming for the Model-View-Controller pattern. Models abstract the used data by defining classes for them and storing them in relational tables. Views take the job of the controllers in MVC and basically define, what the user gets to see. Functions, not classes here. Templates define how the users see the view 11 / 34
  • 9. What is Django? General Features What do you need? References Projects and Applications Project A project is for example your whole website. Here you store your central configuration and general templates and images (just as an example). Applications are where you store the actual functionality. For example a weblog would be an application. An account system would be an application ... Applications are a simple way to share common functionality between various projects. 12 / 34
  • 10. What is Django? General Features What do you need? References Easy start Python2 (ideally 2.5 since sqlite is bundled with it) a text editor This is all you need to start developing with Django since Django comes with its own lightweight webserver to make it very easy for everyone to start playing around with it. 2 http://www.python.org 13 / 34
  • 11. What is Django? General Features What do you need? References Yet flexible SQLite FastCGI MySQL mod python PostgreSQL mod wsgi Oracle in preparation 14 / 34
  • 12. What is Django? Contributed apps Features The Template Language References Simple Form Processing Main features (for me) A good collection of contributed applications Administration interface Authentication system Comments system ... Template language focused on inheritance Simple form processing No magic 15 / 34
  • 13. What is Django? Contributed apps Features The Template Language References Simple Form Processing Administration interface I 16 / 34
  • 14. What is Django? Contributed apps Features The Template Language References Simple Form Processing Administration interface II Available in django.contrib.admin Configured through model definitions Configurable using templates (possible per model), JavaScripts and CSS Currently a rewrite using newforms is in the pipe. 17 / 34
  • 15. What is Django? Contributed apps Features The Template Language References Simple Form Processing Authentication system3 django.contrib.auth Just hook it in, and you get a login screen ... and usergroups ... and custom permissions 3 http://www.djangoproject.com/documentation/authentication/ 18 / 34
  • 16. What is Django? Contributed apps Features The Template Language References Simple Form Processing django-registration5 By James Bennett4 Offers all you really need: Simple registration form E-mail activation Works with django.contrib.auth 4 http://www.b-list.org/about/ 5 http://code.google.com/p/django-registration/ 19 / 34
  • 17. What is Django? Contributed apps Features The Template Language References Simple Form Processing The Template Language Very restrictive ... to keep application logic within the View and the Model Don’t let templates change the state of your site! If you want to have complex code in your templates, you have to define your own template tags in Python. Inheritance between templates You have to pass variables explicitly to the template from the view 20 / 34
  • 18. What is Django? Contributed apps Features The Template Language References Simple Form Processing Template Basics Variables Rendered with {{ variable_name }} Tags allow you to do more sophisticated stuff while keeping the actual Python code out of the template: {% template_tag %} Even conditional blocks are realized as tags. Filters allow you to manipulate the output of a variable: {{ variable|filter }} E.g.: Escaping strings, converting from Markdown to HTML, ... 22 / 34
  • 19. What is Django? Contributed apps Features The Template Language References Simple Form Processing Template Inheritance6 The core of inheritance are blocks the templates. base.html index.html <html> {% extends ’base.html’ %} <body> {% block title %} <h1> Index page {% block title %} {% endblock %} {% endblock %} {% block content %} </h1> ... <div id=quot;contentquot;> {% endblock %} {% block content %} {% endblock %} </div> </body> </html> 6 http://www.djangoproject.com/documentation/templates/ #template-inheritance 24 / 34
  • 20. What is Django? Contributed apps Features The Template Language References Simple Form Processing newforms7 ”newforms” because there was something before that ... let’s ignore the only form processing for now ;-) Easy way to define forms ... to render them ... and to validate their data Easily combinable with models (as you will see in the demoapp) 7 http://www.djangoproject.com/documentation/newforms/ 25 / 34
  • 21. What is Django? Contributed apps Features The Template Language References Simple Form Processing Form definition from d j a n g o import newforms a s f o r m s c l a s s CommentForm ( m o d e l s . Form ) : a u t h o r = form . C h a r F i e l d ( ’ Your name ’ ) e m a i l = form . E m a i l F i e l d ( ’ Your e−m a i l ) body = form . C h a r F i e l d ( ’ Comment ’ , w i d g e t=f o r m s . T e x t a r e a ( ) ) 27 / 34
  • 22. What is Django? Contributed apps Features The Template Language References Simple Form Processing Form output {{ form . a s p }} Results in: <p> a b e l f o r=” i d a u t h o r ”>Your name :</ l a b e l> <l <i n p u t i d=” i d a u t h o r ” t y p e=” t e x t ” name=” a u t h o r ” m a x l e n g t h=” 100 ” /></p> <p> a b e l f o r=” i d e m a i l ”>Your e−m a i l :</ l a b e l> <l <i n p u t i d=” i d e m a i l ” t y p e=” t e x t ” name=” e m a i l ” m a x l e n g t h=” 75 ” /> </p> <p> a b e l f o r=” i d b o d y ”>Comment :</ l a b e l> <l <t e x t a r e a i d=” i d b o d y ” rows=” 10 ” c o l s=” 40 ” name=” body ”> t e x t a r e a> </ </p> 29 / 34
  • 23. What is Django? Contributed apps Features The Template Language References Simple Form Processing Form data validation Everything is done in Python, so it’s easily re-usable. c l a s s CommentForm ( f o r m s . Form ) : # ... def c l e a n e m a i l ( s e l f ) : e m a i l = s e l f . c l e a n e d d a t a [ ” e m a i l ” ] . s p l i t ( ”@” ) [ 1 ] i f e m a i l i n [ ” h o t m a i l . com” , ” yahoo . com” ] : r a i s e V a l i d a t i o n E r r o r , ” Get a GMail a c c o u n t ! ” 31 / 34
  • 24. What is Django? Features References “Django project site.” [Online]. Available: http://www.djangoproject.com/ 32 / 34
  • 25. What is Django? Features References Thank you for your attention. Any last question? 33 / 34
  • 26. What is Django? Features References Want to get some action? If you liked what you saw, we could meet somewhere and build a little website together :-) 34 / 34