You've done the Django Tutorial, what next?

1,815 views

Published on

Some suggestions on where to look next when building that next Django site

Published in: Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,815
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

You've done the Django Tutorial, what next?

  1. 1. You’ve done the Django tutorial. What next? Andy McKay Clearwind Consulting @clearwind
  2. 2. build something
  3. 3. my opinions, likely wrong
  4. 4. 1. Setting up 2. Writing models 3. Middle years 4. Avoid 5. Tools
  5. 5. Part I: Setting up
  6. 6. app vs project vs...
  7. 7. past caring
  8. 8. app directory
  9. 9. (a). base templates
  10. 10. (b). context processor http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own- context-processors
  11. 11. def context(request): data = {} return data
  12. 12. (c). render shortcuts eg: http://www.djangosnippets.org/snippets/1022/
  13. 13. (d). site constants
  14. 14. (e) your middleware http://docs.djangoproject.com/en/1.1/topics/http/middleware/#writing-your- own-middleware
  15. 15. (f) your auth. backend http://docs.djangoproject.com/en/dev/topics/auth/#topics-auth
  16. 16. (g) base classes
  17. 17. model base class
  18. 18. class Base(models.Model): class Meta: abstract = True
  19. 19. form base class
  20. 20. class Form(forms.Form): ! pass class ModelForm(forms.ModelForm): ! pass
  21. 21. Part 2: Writing models
  22. 22. (a) fixtures
  23. 23. not just for testing
  24. 24. create data in admin
  25. 25. manage.py dumpdata
  26. 26. (b) migration
  27. 27. during development
  28. 28. reset script http://www.agmweb.ca/blog/andy/2154/
  29. 29. drop db, create db, syncdb, load fixtures, start up server etc...
  30. 30. my workflow
  31. 31. 1. create app within project 2. define models 3. access admin 4. smoke test models 5. alter, run “reset” 6. access admin (back to 4 until happy) 7. enter sample data 8. dump data to fixtures 9. add fixture loading to “reset” 10. continue... write tests and retail view
  32. 32. at some point... beta?
  33. 33. South http://south.aeracode.org/
  34. 34. Part 3: The middle years
  35. 35. (a) signals
  36. 36. great for decoupling http://docs.djangoproject.com/en/dev/ref/signals/ #ref-signals
  37. 37. signals.pre_save.connect( ! add_profile, ! sender=User)
  38. 38. custom signals http://docs.djangoproject.com/en/dev/topics/signals/#defining-and-sending- signals
  39. 39. (b) URLs
  40. 40. always use named urls http://docs.djangoproject.com/en/dev/topics/http/urls/#url
  41. 41. urlpatterns = patterns('', url(r'^index/$', index_view, name="main-view"), ... )
  42. 42. reverse(“main-view”)
  43. 43. {% url main-view %}
  44. 44. (c) class based views http://www.slideshare.net/simon/ classbased-views-with-django
  45. 45. def boring(request): ... return some_html
  46. 46. class boring: def get(request): ... return some_html
  47. 47. Part 4: Avoid these
  48. 48. generic views http://docs.djangoproject.com/en/dev/ref/generic-views/
  49. 49. push logic into urls, always need rewriting
  50. 50. custom template tags (maybe)
  51. 51. complicated templates
  52. 52. {% div %} {% dl %} {% dt %}Name{% enddt %} {% dd %}Definition{% enddd %} {% enddl %} {% enddiv %}
  53. 53. some of django.contrib...
  54. 54. comments
  55. 55. Part 5: Debug Tools
  56. 56. pdb http://docs.python.org/library/pdb.html
  57. 57. pdb http://docs.python.org/library/pdb.html (not optional)
  58. 58. ipython http://ipython.scipy.org/moin/
  59. 59. ipdb http://pypi.python.org/pypi/ipdb
  60. 60. django debug toolbar http://github.com/robhudson/django-debug-toolbar
  61. 61. command extensions http://code.google.com/p/django-command-extensions/
  62. 62. arecibo http://areciboapp.com (disclaimer)
  63. 63. Fin. Questions? Andy McKay Clearwind Consulting @clearwind

×