SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Developing with Django
          Daniel Ryan
       http://dryan.com
Some Background
Some Background


• Lawrence Journal-World
Some Background


• Lawrence Journal-World
• Ellington
Some Background


• Lawrence Journal-World
• Ellington
• Pycon 2005
Sites Powered by Django
Acronyms Abound
Acronyms Abound


• MTV - Model • Template • View
Acronyms Abound


• MTV - Model • Template • View
• DRY - Don’t Repeat Yourself
Acronyms Abound


• MTV - Model • Template • View
• DRY - Don’t Repeat Yourself
• ORM - Object-relational Mapping
MTV vs. MVC
MTV vs. MVC


• Model = Model
MTV vs. MVC


• Model = Model
• Template = View
MTV vs. MVC


• Model = Model
• Template = View
• View = Controller
Installing Django
Installing Django

• Check out http://dryan.com/articles/snow-
  leopard-64bit-mamp/#python
Installing Django

• Check out http://dryan.com/articles/snow-
  leopard-64bit-mamp/#python

• Python
Installing Django

• Check out http://dryan.com/articles/snow-
  leopard-64bit-mamp/#python

• Python
• Trunk versus Stable Release
Installing Django

• Check out http://dryan.com/articles/snow-
  leopard-64bit-mamp/#python

• Python
• Trunk versus Stable Release
• Third Party Libraries
A Django Workflow
A Django Workflow

• Create a project
A Django Workflow

• Create a project
• Configure settings.py
A Django Workflow

• Create a project
• Configure settings.py
• Configure urls.py
A Django Workflow

• Create a project
• Configure settings.py
• Configure urls.py
• Create the database tables
A Django Workflow
A Django Workflow
• Create an app
A Django Workflow
• Create an app
• Define your models
A Django Workflow
• Create an app
• Define your models
• Create the database tables
A Django Workflow
• Create an app
• Define your models
• Create the database tables
• Define your urls
A Django Workflow
• Create an app
• Define your models
• Create the database tables
• Define your urls
• Define your views
A Django Workflow
• Create an app
• Define your models
• Create the database tables
• Define your urls
• Define your views
• Create your templates
Reduce, Reuse, Recycle
      Django Generic Views
Reduce, Reuse, Recycle
                       Django Generic Views

• direct_to_template               • archive_today
• redirect_to                      • object_detail (date based)
• archive_index                    • object_list
• archive_year                     • object_detail (list based)
• archive_month                    • create_object
• archive_week                     • update_object
• archive_day                      • delete_object
Django Templates
Django Templates
• Just like PHP, except the exact opposite
Django Templates
• Just like PHP, except the exact opposite
• True separation of logic and presentation
Django Templates
• Just like PHP, except the exact opposite
• True separation of logic and presentation
• Global templates vs. app templates
Django Templates
• Just like PHP, except the exact opposite
• True separation of logic and presentation
• Global templates vs. app templates
• Blocks
Django Templates
• Just like PHP, except the exact opposite
• True separation of logic and presentation
• Global templates vs. app templates
• Blocks
• Tags
Django Templates
• Just like PHP, except the exact opposite
• True separation of logic and presentation
• Global templates vs. app templates
• Blocks
• Tags
• Filters
Built-in Tags
Built-in Tags
•   autoescape     •   for             •   now

•   block          •   for ... empty   •   regroup

•   comment        •   if              •   spaceless

•   cycle          •   ifchanged       •   ssi

•   debug          •   ifequal         •   templatetag

•   extends        •   ifnotequal      •   url

•   filter          •   include         •   widthratio

•   firstof         •   load            •   with
Built-in Filters
Built-in Filters
•   add               •   escape          •   length         •   random         •   title

•   addslashes        •   escapejs        •   length_is      •   removetags     •   truncatewords

•   capfirst           •   filesizeformat   •   linebreaks     •   rjust          •   truncatewords_
                                                                                    html
•   center            •   first            •   linebreaksbr   •   safe
                                                                                •   unordered_list
•   cut               •   fix_ampersand    •   linenumbers    •   safeseq
                          s                                                     •   upper
•   date                                  •   ljust          •   slice
                      •   floatformat                                            •   urlencode
•   default                               •   lower          •   slugify
                      •   force_escape                                          •   urlize
•   default_if_none                       •   make_list      •   stringformat
                      •   get_digit                                             •   urlizetrunc
•   dictsort                              •   phone2numeri   •   striptags
                      •   iriencode           c                                 •   wordcount
•   dictsortreverse                                          •   time
    d                 •   join            •   pluralize                         •   wordwrap
                                                             •   timesince
•   divisibleby       •   last            •   pprint                            •   yesno
                                                             •   timeuntil
Other Freebies
    django.contrib
Other Freebies
                                 django.contrib
•   Admin site               •   E-mail (sending)       •   Sessions

•   Authentication           •   Flatpages              •   Signals

•   Cache system             •   Humanize               •   Sitemaps

•   Conditional content      •   Internationalization   •   Sites
    processing
                             •   Jython support         •   Syndication feeds (RSS/
•   Comments                                                Atom)
                             •   “Local flavor”
•   Content types                                       •   Unicode in Django
                             •   Pagination
•   Cross Site Request                                  •   Web design helpers
    Forgery protection       •   Redirects

•   Databrowse               •   Serialization
Resources
Resources

• http://docs.djangoproject.com
Resources

• http://docs.djangoproject.com
• irc://irc.freenode.net/django
Resources

• http://docs.djangoproject.com
• irc://irc.freenode.net/django
• http://thisweekindjango.com/
Resources

• http://docs.djangoproject.com
• irc://irc.freenode.net/django
• http://thisweekindjango.com/
• http://www.djangosnippets.org/
Resources

• http://docs.djangoproject.com
• irc://irc.freenode.net/django
• http://thisweekindjango.com/
• http://www.djangosnippets.org/
• http://code.djangoproject.com/wiki/Tutorials

Weitere ähnliche Inhalte

Ähnlich wie Developing With Django

SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
Korea Sdec
 
DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻
都元ダイスケ Miyamoto
 
WTF TDD?
WTF TDD?WTF TDD?
WTF TDD?
jeremyw
 
Getting the most out of Radiant
Getting the most out of RadiantGetting the most out of Radiant
Getting the most out of Radiant
jomz83
 

Ähnlich wie Developing With Django (20)

Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011
 
An Evening with MongoDB - Orlando: Welcome and Keynote
An Evening with MongoDB - Orlando: Welcome and KeynoteAn Evening with MongoDB - Orlando: Welcome and Keynote
An Evening with MongoDB - Orlando: Welcome and Keynote
 
初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料
 
PHP Classroom Training
PHP Classroom TrainingPHP Classroom Training
PHP Classroom Training
 
Client-side MVC with Backbone.js
Client-side MVC with Backbone.js Client-side MVC with Backbone.js
Client-side MVC with Backbone.js
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)
 
[2010]我有一个梦想
[2010]我有一个梦想[2010]我有一个梦想
[2010]我有一个梦想
 
Becoming a more productive Rails Developer
Becoming a more productive Rails DeveloperBecoming a more productive Rails Developer
Becoming a more productive Rails Developer
 
DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻
 
Scala.io
Scala.ioScala.io
Scala.io
 
Nguyen phuong truong anh a story of bug bounty hunter
Nguyen phuong truong anh   a story of bug bounty hunterNguyen phuong truong anh   a story of bug bounty hunter
Nguyen phuong truong anh a story of bug bounty hunter
 
WTF TDD?
WTF TDD?WTF TDD?
WTF TDD?
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - English
 
Torquebox rubyhoedown-2012
Torquebox rubyhoedown-2012Torquebox rubyhoedown-2012
Torquebox rubyhoedown-2012
 
Drupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin SystemDrupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin System
 
下吧开发总结
下吧开发总结下吧开发总结
下吧开发总结
 
Polyglot Grails
Polyglot GrailsPolyglot Grails
Polyglot Grails
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
 
Getting the most out of Radiant
Getting the most out of RadiantGetting the most out of Radiant
Getting the most out of Radiant
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Developing With Django