This document provides an overview and introduction to Django beyond the basics. It begins by stating that the presentation aims to share experiences and advocacy rather than being a comprehensive tutorial. It then discusses what Django is and is not, emphasizing that it is a framework, not a CMS. Several core Django components and features are listed, and reasons why Django is considered awesome are provided. The document then addresses considerations for those coming from PHP/ASP backgrounds. It discusses Django best practices and packages that are useful when using Django. Common novice Django questions are also covered. The document concludes with the presenter's typical Django workflow.
6. Disclaimer
This presentationdoesnot aim tobe a
comprehensiveoverviewof any part of Django.
Thereare severaltutorialscoveringvarious
aspectsof theframework. Insteadthisis talkis
part experiencesharing,part advocacyand
part entertainment.
34. Must-learn Django Packages
• Django-debug-toolbar– Only inDEV!
• Django_compressor– Notjust compression
• Django-extensions– Tonsof goodies
• South– Gettingintegrated?
• Celery– DelayedGratification
• Tastypie*–Build yummy APIs
* Or anything that suits you
35. Other cool Django Packages
• Djangosocialauth:One app to most Social logins
• DjangoPaypal:PayPal Payments Standard & Pro
• crispy-forms:NiceHTML for forms
• django-taggit:Implement tags easily
• Psycopg2: Talk to PostgreSQL, a solid database
• django-storages:Store anywhere - Cloud, DB or FTP
37. 1) Create a new Django project
2) Find a3rd party app or create anapp
3) Write/Improve models.py
4) Play with queries onconsole. Run syncdb.
5) Add abare admin.py
6) Add data from admin UI
7) Write views.py. Leverage CBVs
8) If needed, adda model form to forms.py
9) Add views to urls.py
10) Jump to step 3till app looks good
11) jump to step 2
For examples, head to arunrocks.com
A simplistic Django workflow…
38. 1) Create a new Django project
2) Find a3rd party app or create an app
3) Write/Improve models.py
4) Play with queries onconsole. Repeat step 3
5) Add abare admin.py
6) Add data from admin UI
7) Write views.py. Leverage CBVs
8) If needed, adda model form to forms.py
9) Add views to urls.py
10) Jump to step 3till app looks good
Make friends with Git, South, Fabric…
A better Django workflow…
$ ./manage.py schemamigration app --initial
$ ./manage.py migrate app
$ ./manage.py schemamigration app --auto
$ git init
Write tests.py
Fabric/Puppet/Chef
40. Forms are easy!
• Use formsas much as possible(Hint:security)
• ModelFormscovermost uses case
• Butselect whichfields showin ModelForms
• Hard set all defaults beforeform.save
• FormViewis a greatgenericviewfor forms
• Usingbootstrap?Use crispy-formsto savetime
43. Ok, I made a Django site. Now what?
• Turn off DEBUG
• Use HTTPS logins
• Set X-Frame-
Optionsheader
• Use SESSION_COOKIE_
SECURE
• Change /admin/ url Oreasier,go to
http://ponycheckup.com/