SlideShare a Scribd company logo
1 of 23
Download to read offline
Django Worst Practices
                          Daniel Greenfeld




Tuesday, April 19, 2011
Django Worst Practices

                           Whole
                          project in
                           one app



Tuesday, April 19, 2011
Django Worst Practices

                           Whole
                          project in
                           one app

                               All your stuff in one place!


Tuesday, April 19, 2011
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
Django Worst Practices
  pydanny: pwd
  /Users/pydanny/projects/enterprise/settings
  pydanny: ls -l
  total 24
  -rw-r--r-- 1 pydanny staff 0 Apr 18 22:38 __init__.py
  lrwxr-xr-x 1 pydanny staff 21 Apr 18 22:42 dev.py -> /Users/pydanny/dev.py
  lrwxr-xr-x 1 pydanny staff 22 Apr 18 22:42 prod.py -> /Users/pydanny/prod.py
  lrwxr-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
Django Worst Practices
                          Database Choices




Tuesday, April 19, 2011
Django Worst Practices
                              Database Choices
                     • Use a relational database to store ill-
                          defined hierarchical data!




Tuesday, April 19, 2011
Django Worst Practices
                              Database Choices
                     • Use a relational database to store ill-
                          defined hierarchical data!
                     • Use NoSQL to store tabular data!


Tuesday, April 19, 2011
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
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>


                          Who needs caching?



Tuesday, April 19, 2011
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>


                             Who needs caching?
                          Performance awesomeness!

Tuesday, April 19, 2011
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>


                                Who needs caching?
                            Performance awesomeness!
                          Replaces pesky django templates!
Tuesday, April 19, 2011
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>


                                Who needs caching?
                            Performance awesomeness!
                          Replaces pesky django templates!
Tuesday, April 19, 2011
Django Worst Practices
                            <?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>




                          Use XSLT for awesome performance!


Tuesday, April 19, 2011
Django Worst Practices
                          Put critical business logic in...




Tuesday, April 19, 2011
Django Worst Practices
                          Put critical business logic in...

                                  • The templates




Tuesday, April 19, 2011
Django Worst Practices
                          Put critical business logic in...

                                  • The templates
                                  • settings




Tuesday, April 19, 2011
Django Worst Practices
                          Put critical business logic in...

                                  • The templates
                                  • settings
                                  • The context processors



Tuesday, April 19, 2011
Django Worst Practices
                          Put critical business logic in...

                                  •   The templates
                                  •   settings
                                  •   The context processors
                                  •   Middleware!



Tuesday, April 19, 2011
Django Worst Practices


                          Use metaclasses instead of abstract models!




Tuesday, April 19, 2011
Django Worst Practices
   In settings:
                from django.db import models
                blog2_fields = [
                          models.CharField(“title”, max_length=50),
                          models.TextField(“note”)
                ]

Tuesday, April 19, 2011
Django Worst Practices

                           Present using
                           Different fonts
                             Dark text
                          Dire backgrounds

Tuesday, April 19, 2011
Django Worst Practices
                                       Don’t use



                          http://djangopackages.com

                               Invent everything yourself!



Tuesday, April 19, 2011

More Related Content

More from Daniel Greenfeld

How to Write a Popular Python Library by Accident
How to Write a Popular Python Library by AccidentHow to Write a Popular Python Library by Accident
How to Write a Popular Python Library by AccidentDaniel Greenfeld
 
10 more-things-you-can-do-with-python
10 more-things-you-can-do-with-python10 more-things-you-can-do-with-python
10 more-things-you-can-do-with-pythonDaniel Greenfeld
 
From NASA to Startups to Big Commerce
From NASA to Startups to Big CommerceFrom NASA to Startups to Big Commerce
From NASA to Startups to Big CommerceDaniel Greenfeld
 
Thinking hard about_python
Thinking hard about_pythonThinking hard about_python
Thinking hard about_pythonDaniel Greenfeld
 
Intro to Data Visualizations
Intro to Data VisualizationsIntro to Data Visualizations
Intro to Data VisualizationsDaniel Greenfeld
 
An Extreme Talk about the Zen of Python
An Extreme Talk about the Zen of PythonAn Extreme Talk about the Zen of Python
An Extreme Talk about the Zen of PythonDaniel Greenfeld
 
PyCon Philippines 2012 Keynote
PyCon Philippines 2012 KeynotePyCon Philippines 2012 Keynote
PyCon Philippines 2012 KeynoteDaniel Greenfeld
 
Round pegs and square holes
Round pegs and square holesRound pegs and square holes
Round pegs and square holesDaniel Greenfeld
 
Lighting talk on django-social-auth
Lighting talk on django-social-authLighting talk on django-social-auth
Lighting talk on django-social-authDaniel Greenfeld
 
Advanced Django Forms Usage
Advanced Django Forms UsageAdvanced Django Forms Usage
Advanced Django Forms UsageDaniel Greenfeld
 
Confessions of Joe Developer
Confessions of Joe DeveloperConfessions of Joe Developer
Confessions of Joe DeveloperDaniel Greenfeld
 
Pinax Long Tutorial Slides
Pinax Long Tutorial SlidesPinax Long Tutorial Slides
Pinax Long Tutorial SlidesDaniel Greenfeld
 

More from Daniel Greenfeld (20)

How to Write a Popular Python Library by Accident
How to Write a Popular Python Library by AccidentHow to Write a Popular Python Library by Accident
How to Write a Popular Python Library by Accident
 
10 more-things-you-can-do-with-python
10 more-things-you-can-do-with-python10 more-things-you-can-do-with-python
10 more-things-you-can-do-with-python
 
From NASA to Startups to Big Commerce
From NASA to Startups to Big CommerceFrom NASA to Startups to Big Commerce
From NASA to Startups to Big Commerce
 
Thinking hard about_python
Thinking hard about_pythonThinking hard about_python
Thinking hard about_python
 
Intro to Data Visualizations
Intro to Data VisualizationsIntro to Data Visualizations
Intro to Data Visualizations
 
An Extreme Talk about the Zen of Python
An Extreme Talk about the Zen of PythonAn Extreme Talk about the Zen of Python
An Extreme Talk about the Zen of Python
 
PyCon Philippines 2012 Keynote
PyCon Philippines 2012 KeynotePyCon Philippines 2012 Keynote
PyCon Philippines 2012 Keynote
 
Round pegs and square holes
Round pegs and square holesRound pegs and square holes
Round pegs and square holes
 
Intro
IntroIntro
Intro
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Lighting talk on django-social-auth
Lighting talk on django-social-authLighting talk on django-social-auth
Lighting talk on django-social-auth
 
Future of Collaboration
Future of CollaborationFuture of Collaboration
Future of Collaboration
 
Advanced Django Forms Usage
Advanced Django Forms UsageAdvanced Django Forms Usage
Advanced Django Forms Usage
 
The One Way
The One WayThe One Way
The One Way
 
Confessions of Joe Developer
Confessions of Joe DeveloperConfessions of Joe Developer
Confessions of Joe Developer
 
Python Worst Practices
Python Worst PracticesPython Worst Practices
Python Worst Practices
 
How to sell django panel
How to sell django panelHow to sell django panel
How to sell django panel
 
Pinax Long Tutorial Slides
Pinax Long Tutorial SlidesPinax Long Tutorial Slides
Pinax Long Tutorial Slides
 
Testing In Django
Testing In DjangoTesting In Django
Testing In Django
 
Django Uni-Form
Django Uni-FormDjango Uni-Form
Django Uni-Form
 

Recently uploaded

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Recently uploaded (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Django Worst Practices

  • 1. Django Worst Practices Daniel Greenfeld Tuesday, April 19, 2011
  • 2. Django Worst Practices Whole project in one app Tuesday, April 19, 2011
  • 3. Django Worst Practices Whole project in one app All your stuff in one place! Tuesday, April 19, 2011
  • 4. 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
  • 5. Django Worst Practices pydanny: pwd /Users/pydanny/projects/enterprise/settings pydanny: ls -l total 24 -rw-r--r-- 1 pydanny staff 0 Apr 18 22:38 __init__.py lrwxr-xr-x 1 pydanny staff 21 Apr 18 22:42 dev.py -> /Users/pydanny/dev.py lrwxr-xr-x 1 pydanny staff 22 Apr 18 22:42 prod.py -> /Users/pydanny/prod.py lrwxr-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
  • 6. Django Worst Practices Database Choices Tuesday, April 19, 2011
  • 7. Django Worst Practices Database Choices • Use a relational database to store ill- defined hierarchical data! Tuesday, April 19, 2011
  • 8. Django Worst Practices Database Choices • Use a relational database to store ill- defined hierarchical data! • Use NoSQL to store tabular data! Tuesday, April 19, 2011
  • 9. 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
  • 10. 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> Who needs caching? Tuesday, April 19, 2011
  • 11. 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> Who needs caching? Performance awesomeness! Tuesday, April 19, 2011
  • 12. 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> Who needs caching? Performance awesomeness! Replaces pesky django templates! Tuesday, April 19, 2011
  • 13. 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> Who needs caching? Performance awesomeness! Replaces pesky django templates! Tuesday, April 19, 2011
  • 14. Django Worst Practices <?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> Use XSLT for awesome performance! Tuesday, April 19, 2011
  • 15. Django Worst Practices Put critical business logic in... Tuesday, April 19, 2011
  • 16. Django Worst Practices Put critical business logic in... • The templates Tuesday, April 19, 2011
  • 17. Django Worst Practices Put critical business logic in... • The templates • settings Tuesday, April 19, 2011
  • 18. Django Worst Practices Put critical business logic in... • The templates • settings • The context processors Tuesday, April 19, 2011
  • 19. Django Worst Practices Put critical business logic in... • The templates • settings • The context processors • Middleware! Tuesday, April 19, 2011
  • 20. Django Worst Practices Use metaclasses instead of abstract models! Tuesday, April 19, 2011
  • 21. Django Worst Practices In settings: from django.db import models blog2_fields = [ models.CharField(“title”, max_length=50), models.TextField(“note”) ] Tuesday, April 19, 2011
  • 22. Django Worst Practices Present using Different fonts Dark text Dire backgrounds Tuesday, April 19, 2011
  • 23. Django Worst Practices Don’t use http://djangopackages.com Invent everything yourself! Tuesday, April 19, 2011