django worst practices
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.TRANSCRIPT
![Page 1: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/1.jpg)
Django Worst PracticesDaniel Greenfeld
Tuesday, April 19, 2011
![Page 2: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/2.jpg)
Django Worst Practices
Whole project in one app
Tuesday, April 19, 2011
![Page 3: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/3.jpg)
Django Worst Practices
Whole project in one app
All your stuff in one place!
Tuesday, April 19, 2011
![Page 4: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/4.jpg)
Django Worst Practices
Whole project in one app
All your stuff in one place!No need to worry about bugfixes or enhancements!
Tuesday, April 19, 2011
![Page 5: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/5.jpg)
Django Worst Practices
pydanny: 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.py
Symlink your settings folder!Cause you’ll remember to do this with each server setup...
Tuesday, April 19, 2011
![Page 6: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/6.jpg)
Django Worst Practices
Database Choices
Tuesday, April 19, 2011
![Page 7: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/7.jpg)
Django Worst Practices
• Use a relational database to store ill-defined hierarchical data!
Database Choices
Tuesday, April 19, 2011
![Page 8: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/8.jpg)
Django Worst Practices
• Use a relational database to store ill-defined hierarchical data!
• Use NoSQL to store tabular data!
Database Choices
Tuesday, April 19, 2011
![Page 9: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/9.jpg)
Django Worst Practices <%python scope="global"> # declare global variables, accessible # across this component's generated module message1 = "this is message one." message2 = "this is message two." message3 = "doh, im message three." </%python> <%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>
Tuesday, April 19, 2011
![Page 10: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/10.jpg)
Django Worst Practices
Who needs caching?
<%python scope="global"> # declare global variables, accessible # across this component's generated module message1 = "this is message one." message2 = "this is message two." message3 = "doh, im message three." </%python> <%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>
Tuesday, April 19, 2011
![Page 11: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/11.jpg)
Django Worst Practices
Who needs caching?
Performance awesomeness!
<%python scope="global"> # declare global variables, accessible # across this component's generated module message1 = "this is message one." message2 = "this is message two." message3 = "doh, im message three." </%python> <%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>
Tuesday, April 19, 2011
![Page 12: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/12.jpg)
Django Worst Practices
Who needs caching?
Performance awesomeness!
Replaces pesky django templates!
<%python scope="global"> # declare global variables, accessible # across this component's generated module message1 = "this is message one." message2 = "this is message two." message3 = "doh, im message three." </%python> <%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>
Tuesday, April 19, 2011
![Page 13: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/13.jpg)
Django Worst Practices
Who needs caching?
Performance awesomeness!
Replaces pesky django templates!
<%python scope="global"> # declare global variables, accessible # across this component's generated module message1 = "this is message one." message2 = "this is message two." message3 = "doh, im message three." </%python> <%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>
Tuesday, April 19, 2011
![Page 14: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/14.jpg)
Django Worst Practices
Use XSLT for awesome performance!
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/persons"> <root> <xsl:apply-templates select="person"/> </root> </xsl:template> <xsl:template match="person"> <name username="{@username}"> <xsl:value-of select="name" /> </name> </xsl:template> </xsl:stylesheet>
Tuesday, April 19, 2011
![Page 15: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/15.jpg)
Django Worst Practices
Put critical business logic in...
Tuesday, April 19, 2011
![Page 16: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/16.jpg)
Django Worst Practices
• The templates
Put critical business logic in...
Tuesday, April 19, 2011
![Page 17: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/17.jpg)
Django Worst Practices
• The templates
• settings
Put critical business logic in...
Tuesday, April 19, 2011
![Page 18: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/18.jpg)
Django Worst Practices
• The templates
• settings
• The context processors
Put critical business logic in...
Tuesday, April 19, 2011
![Page 19: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/19.jpg)
Django Worst Practices
• The templates
• settings
• The context processors
• Middleware!
Put critical business logic in...
Tuesday, April 19, 2011
![Page 20: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/20.jpg)
Django Worst Practices
Use metaclasses instead of abstract models!
Tuesday, April 19, 2011
![Page 21: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/21.jpg)
Django Worst Practices
from django.db import models
blog2_fields = [
models.CharField(“title”, max_length=50),
models.TextField(“note”)
]
In settings:
Tuesday, April 19, 2011
![Page 22: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/22.jpg)
Django Worst Practices
Present usingDifferent fonts
Dark textDire backgrounds
Tuesday, April 19, 2011
![Page 23: Django Worst Practices](https://reader033.vdocuments.site/reader033/viewer/2022052321/554dae18b4c905fa7a8b4f98/html5/thumbnails/23.jpg)
Django Worst PracticesDon’t use
http://djangopackages.com
Invent everything yourself!
Tuesday, April 19, 2011