SlideShare a Scribd company logo
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 Accident
Daniel 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-python
Daniel 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_python
Daniel Greenfeld
 
Intro to Data Visualizations
Intro to Data VisualizationsIntro to Data Visualizations
Intro to Data Visualizations
Daniel 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 Python
Daniel Greenfeld
 
PyCon Philippines 2012 Keynote
PyCon Philippines 2012 KeynotePyCon Philippines 2012 Keynote
PyCon Philippines 2012 Keynote
Daniel Greenfeld
 
Round pegs and square holes
Round pegs and square holesRound pegs and square holes
Round pegs and square holes
Daniel Greenfeld
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
Daniel Greenfeld
 
Lighting talk on django-social-auth
Lighting talk on django-social-authLighting talk on django-social-auth
Lighting talk on django-social-auth
Daniel Greenfeld
 
Future of Collaboration
Future of CollaborationFuture of Collaboration
Future of Collaboration
Daniel Greenfeld
 
Advanced Django Forms Usage
Advanced Django Forms UsageAdvanced Django Forms Usage
Advanced Django Forms Usage
Daniel Greenfeld
 
Confessions of Joe Developer
Confessions of Joe DeveloperConfessions of Joe Developer
Confessions of Joe Developer
Daniel Greenfeld
 
Python Worst Practices
Python Worst PracticesPython Worst Practices
Python Worst Practices
Daniel Greenfeld
 
Pinax Long Tutorial Slides
Pinax Long Tutorial SlidesPinax Long Tutorial Slides
Pinax Long Tutorial Slides
Daniel Greenfeld
 
Testing In Django
Testing In DjangoTesting In Django
Testing In Django
Daniel Greenfeld
 
Django Uni-Form
Django Uni-FormDjango Uni-Form
Django Uni-Form
Daniel 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

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

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