Developing With Django

2,727 views
2,581 views

Published on

Slides from my Developing with Django presentation

Published in: Technology

Developing With Django

  1. 1. Developing with Django Daniel Ryan http://dryan.com
  2. 2. Some Background
  3. 3. Some Background • Lawrence Journal-World
  4. 4. Some Background • Lawrence Journal-World • Ellington
  5. 5. Some Background • Lawrence Journal-World • Ellington • Pycon 2005
  6. 6. Sites Powered by Django
  7. 7. Acronyms Abound
  8. 8. Acronyms Abound • MTV - Model • Template • View
  9. 9. Acronyms Abound • MTV - Model • Template • View • DRY - Don’t Repeat Yourself
  10. 10. Acronyms Abound • MTV - Model • Template • View • DRY - Don’t Repeat Yourself • ORM - Object-relational Mapping
  11. 11. MTV vs. MVC
  12. 12. MTV vs. MVC • Model = Model
  13. 13. MTV vs. MVC • Model = Model • Template = View
  14. 14. MTV vs. MVC • Model = Model • Template = View • View = Controller
  15. 15. Installing Django
  16. 16. Installing Django • Check out http://dryan.com/articles/snow- leopard-64bit-mamp/#python
  17. 17. Installing Django • Check out http://dryan.com/articles/snow- leopard-64bit-mamp/#python • Python
  18. 18. Installing Django • Check out http://dryan.com/articles/snow- leopard-64bit-mamp/#python • Python • Trunk versus Stable Release
  19. 19. Installing Django • Check out http://dryan.com/articles/snow- leopard-64bit-mamp/#python • Python • Trunk versus Stable Release • Third Party Libraries
  20. 20. A Django Workflow
  21. 21. A Django Workflow • Create a project
  22. 22. A Django Workflow • Create a project • Configure settings.py
  23. 23. A Django Workflow • Create a project • Configure settings.py • Configure urls.py
  24. 24. A Django Workflow • Create a project • Configure settings.py • Configure urls.py • Create the database tables
  25. 25. A Django Workflow
  26. 26. A Django Workflow • Create an app
  27. 27. A Django Workflow • Create an app • Define your models
  28. 28. A Django Workflow • Create an app • Define your models • Create the database tables
  29. 29. A Django Workflow • Create an app • Define your models • Create the database tables • Define your urls
  30. 30. A Django Workflow • Create an app • Define your models • Create the database tables • Define your urls • Define your views
  31. 31. A Django Workflow • Create an app • Define your models • Create the database tables • Define your urls • Define your views • Create your templates
  32. 32. Reduce, Reuse, Recycle Django Generic Views
  33. 33. 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
  34. 34. Django Templates
  35. 35. Django Templates • Just like PHP, except the exact opposite
  36. 36. Django Templates • Just like PHP, except the exact opposite • True separation of logic and presentation
  37. 37. Django Templates • Just like PHP, except the exact opposite • True separation of logic and presentation • Global templates vs. app templates
  38. 38. Django Templates • Just like PHP, except the exact opposite • True separation of logic and presentation • Global templates vs. app templates • Blocks
  39. 39. Django Templates • Just like PHP, except the exact opposite • True separation of logic and presentation • Global templates vs. app templates • Blocks • Tags
  40. 40. Django Templates • Just like PHP, except the exact opposite • True separation of logic and presentation • Global templates vs. app templates • Blocks • Tags • Filters
  41. 41. Built-in Tags
  42. 42. 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
  43. 43. Built-in Filters
  44. 44. 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
  45. 45. Other Freebies django.contrib
  46. 46. 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
  47. 47. Resources
  48. 48. Resources • http://docs.djangoproject.com
  49. 49. Resources • http://docs.djangoproject.com • irc://irc.freenode.net/django
  50. 50. Resources • http://docs.djangoproject.com • irc://irc.freenode.net/django • http://thisweekindjango.com/
  51. 51. Resources • http://docs.djangoproject.com • irc://irc.freenode.net/django • http://thisweekindjango.com/ • http://www.djangosnippets.org/
  52. 52. Resources • http://docs.djangoproject.com • irc://irc.freenode.net/django • http://thisweekindjango.com/ • http://www.djangosnippets.org/ • http://code.djangoproject.com/wiki/Tutorials

×