SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
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

Contenu connexe

Similaire à Developing With Django

Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011Jesse Warden
 
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 KeynoteMongoDB
 
初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料Shinichi Ogawa
 
Client-side MVC with Backbone.js
Client-side MVC with Backbone.js Client-side MVC with Backbone.js
Client-side MVC with Backbone.js iloveigloo
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsKorea Sdec
 
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)iloveigloo
 
[2010]我有一个梦想
[2010]我有一个梦想[2010]我有一个梦想
[2010]我有一个梦想Twinsen Liang
 
Becoming a more productive Rails Developer
Becoming a more productive Rails DeveloperBecoming a more productive Rails Developer
Becoming a more productive Rails DeveloperJohn McCaffrey
 
DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻都元ダイスケ Miyamoto
 
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 hunterSecurity Bootcamp
 
WTF TDD?
WTF TDD?WTF TDD?
WTF TDD?jeremyw
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishFlorent Pillet
 
Torquebox rubyhoedown-2012
Torquebox rubyhoedown-2012Torquebox rubyhoedown-2012
Torquebox rubyhoedown-2012Lance Ball
 
Drupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin SystemDrupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin SystemAcquia
 
下吧开发总结
下吧开发总结下吧开发总结
下吧开发总结Night Sailer
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swaggerTony Tam
 
Getting the most out of Radiant
Getting the most out of RadiantGetting the most out of Radiant
Getting the most out of Radiantjomz83
 

Similaire à 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
 

Dernier

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 

Dernier (20)

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 

Developing With Django