Django Worst Practices

Embed Size (px)

DESCRIPTION

Just to be clear, all of these things suck. Please DO NOT use these techniques! It was a joke, and if you attempt any of these things you are making a big mistake.

Text of Django Worst Practices

  • 1.Django Worst PracticesDaniel GreenfeldTuesday, April 19, 2011

2. Django Worst Practices Wholeproject in one appTuesday, April 19, 2011 3. Django Worst Practices Wholeproject in one app All your stuff in one place!Tuesday, April 19, 2011 4. Django Worst Practices Wholeproject in one app All your stuff in one place!No need to worry about bugxes or enhancements!Tuesday, April 19, 2011 5. Django Worst Practicespydanny: pwd/Users/pydanny/projects/enterprise/settingspydanny: ls -ltotal 24-rw-r--r-- 1 pydanny staff 0 Apr 18 22:38 __init__.pylrwxr-xr-x 1 pydanny staff 21 Apr 18 22:42 dev.py -> /Users/pydanny/dev.pylrwxr-xr-x 1 pydanny staff 22 Apr 18 22:42 prod.py -> /Users/pydanny/prod.pylrwxr-xr-x 1 pydanny staff 25 Apr 18 22:42 staging.py -> /Users/pydanny/staging.pySymlink your settings folder!Cause youll remember to do this with each server setup...Tuesday, April 19, 2011 6. Django Worst PracticesDatabase ChoicesTuesday, April 19, 2011 7. Django Worst PracticesDatabase Choices Use a relational database to store ill-dened hierarchical data!Tuesday, April 19, 2011 8. Django Worst PracticesDatabase Choices Use a relational database to store ill-dened hierarchical data! Use NoSQL to store tabular data!Tuesday, April 19, 2011 9. Django Worst Practices# declare global variables, accessible# across this components generated modulemessage1 = "this is message one."message2 = "this is message two."message3 = "doh, im message three."%python># reference the global variablesm.write("message one: " + message1)m.write("message two: " + message2)# we want to assign to message3,# so declare "global" firstglobal message3message3 = "this is message three."m.write("message three: " + message3)%python>Tuesday, April 19, 2011 10. Django Worst Practices# declare global variables, accessible# across this components generated modulemessage1 = "this is message one."message2 = "this is message two."message3 = "doh, im message three."%python># reference the global variablesm.write("message one: " + message1)m.write("message two: " + message2)# we want to assign to message3,# so declare "global" firstglobal message3message3 = "this is message three."m.write("message three: " + message3)%python>Who needs caching?Tuesday, April 19, 2011 11. Django Worst Practices # declare global variables, accessible # across this components generated module message1 = "this is message one." message2 = "this is message two." message3 = "doh, im message three." %python> # reference the global variables m.write("message one: " + message1) m.write("message two: " + message2) # we want to assign to message3, # so declare "global" first global message3 message3 = "this is message three." m.write("message three: " + message3) %python> Who needs caching?Performance awesomeness!Tuesday, April 19, 2011 12. Django Worst Practices# declare global variables, accessible# across this components generated modulemessage1 = "this is message one."message2 = "this is message two."message3 = "doh, im message three."%python># reference the global variablesm.write("message one: " + message1)m.write("message two: " + message2)# we want to assign to message3,# so declare "global" firstglobal message3message3 = "this is message three."m.write("message three: " + message3)%python>Who needs caching?Performance awesomeness!Replaces pesky django templates!Tuesday, April 19, 2011 13. Django Worst Practices# declare global variables, accessible# across this components generated modulemessage1 = "this is message one."message2 = "this is message two."message3 = "doh, im message three."%python># reference the global variablesm.write("message one: " + message1)m.write("message two: " + message2)# we want to assign to message3,# so declare "global" firstglobal message3message3 = "this is message three."m.write("message three: " + message3)%python>Who needs caching?Performance awesomeness!Replaces pesky django templates!Tuesday, April 19, 2011 14. Django Worst PracticesUse XSLT for awesome performance!Tuesday, April 19, 2011 15. Django Worst PracticesPut critical business logic in...Tuesday, April 19, 2011 16. Django Worst PracticesPut critical business logic in... The templatesTuesday, April 19, 2011 17. Django Worst PracticesPut critical business logic in... The templates settingsTuesday, April 19, 2011 18. Django Worst PracticesPut critical business logic in... The templates settings The context processorsTuesday, April 19, 2011 19. Django Worst PracticesPut critical business logic in... The templates settings The context processors Middleware!Tuesday, April 19, 2011 20. Django Worst PracticesUse metaclasses instead of abstract models!Tuesday, April 19, 2011 21. Django Worst Practices In settings:from django.db import modelsblog2_elds = [models.CharField(title, max_length=50),models.TextField(note)]Tuesday, April 19, 2011 22. Django Worst Practices Present using Different fonts Dark textDire backgroundsTuesday, April 19, 2011 23. Django Worst Practices Dont usehttp://djangopackages.com Invent everything yourself!Tuesday, April 19, 2011