SlideShare une entreprise Scribd logo
1  sur  13
Two Scoops of Django
Michelle Leu | 2013/10/29
About the Authors
DjangoPackages.com
the OpenComparison framework. We ran the largest sprint
at PyCon 2011.

PyLadies
a women‟s outreach/mentorship group. Nurturing the group was
basically a 2nd fulltime job for us in 2011.
The first ever PyCon Philippines, a 300-person conference
about the Python programming language held in the Philippines.

LA Open Source Hackathon event series, which brings together
open-source developers from different programming backgrounds.

Audrey Roy
Daniel Greenfeld
Before You Start

Buy the e-book bundle for $17
Buy the print version for $29.95

If you are new to Django ……

Python programming language
Python 2.7.x

Buy the e-book bundle for $17
Django tutorial:
https://docs.djangoproject.com/en
/1.5/intro/tutorial01/.
Django 1.5
Core Concepts
•
•
•
•

Simplicity is the ultimate sophistication.
Fat Models, Helper Modules, Thin Views, Stupid Templates
Start With Django by Default
Stand on the Shoulders of Giants
Make Your Code Readable

•
•
•
•

Avoid abbreviating variable names.
Write out your function argument names.
Document your classes and methods.
Refactor repeated lines of code into reusable functions or
methods.
PEP8
•

Style Guide for Python Code
 “Use 4 spaces per indentation level.”
 “Separate top-level function and class definitions with two
blank lines.”

 “Method definitions inside a class are separated by a single
blank line.”
The Word on Imports

Marketing
Standard library

Training
Core Django

Assesment
Third-party apps

Technology
Your apps

Ex: math

Import from django

Plugins

Imports from the apps
that you created as
part of your Django
project.
The Word on Imports
Use Explicit Relative Imports
Avoid Using Import *

•
•

The reason for this is to avoid implicitly loading all of another
Python module‟s locals into and over our current module‟s
namespace, which can produce unpredictable and sometimes
catastrophic results.
Python Naming Collisions
Django Coding Style Guidelines

•

•

Use underscores (the „_‟ character) in URL pattern names
rather than dashes as this is friendlier to more IDEs and text
editors. Note that we are referring to the name argument of
url() here, not the actual URL typed into the browser. Dashes
in actual URLs are fine.

For the same reason, use underscores rather than dashes in
template block names.
Reference
• Two Scoops of Django:https://django.2scoops.org/
• PEP 8 coding conventions:
http://www.python.org/dev/peps/pep-0008/

•

Django Coding Style
Guidelines:https://docs.djangoproject.com/en/1.5/internals/con
tributing/writing-code/coding-style/

Conclusion
Projects with varying styles are much harder to maintain, slowing development and increasing the
chances of developer mistakes.
Thanks for your listening

Michelle Leu

flywindy2002@gmail.com
Twitter: @flywindy
Developer @ Brand Karma

Contenu connexe

Tendances

Django course final-project
Django course final-projectDjango course final-project
Django course final-project
Udi Bauman
 
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
Casey Kinsey
 
Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practices
eleksdev
 
Django strategy-test
Django strategy-testDjango strategy-test
Django strategy-test
Royce Haynes
 

Tendances (20)

Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to django
 
Django course final-project
Django course final-projectDjango course final-project
Django course final-project
 
Python/Django Training
Python/Django TrainingPython/Django Training
Python/Django Training
 
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
 
Maven beyond hello_world
Maven beyond hello_worldMaven beyond hello_world
Maven beyond hello_world
 
Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practices
 
Django strategy-test
Django strategy-testDjango strategy-test
Django strategy-test
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Unit Test Android Without Going Bald
Unit Test Android Without Going BaldUnit Test Android Without Going Bald
Unit Test Android Without Going Bald
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Nicholas Gustilo "Clean Android: building great mobile apps"
Nicholas Gustilo "Clean Android: building great mobile apps"Nicholas Gustilo "Clean Android: building great mobile apps"
Nicholas Gustilo "Clean Android: building great mobile apps"
 
Maven tutorial for beginners
Maven tutorial for beginnersMaven tutorial for beginners
Maven tutorial for beginners
 
Android Modularization
Android ModularizationAndroid Modularization
Android Modularization
 
Apache Maven - eXo VN office presentation
Apache Maven - eXo VN office presentationApache Maven - eXo VN office presentation
Apache Maven - eXo VN office presentation
 
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
Audit your reactive applications
Audit your reactive applicationsAudit your reactive applications
Audit your reactive applications
 

En vedette

Learning django step 1
Learning django step 1Learning django step 1
Learning django step 1
永昇 陳
 
AngularJS Sharing
AngularJS SharingAngularJS Sharing
AngularJS Sharing
Tom Chen
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師
Tom Chen
 

En vedette (20)

Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做
 
那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子
 
Django workshop homework 3
Django workshop homework 3Django workshop homework 3
Django workshop homework 3
 
Two scoops of Django - Deployment
Two scoops of Django - DeploymentTwo scoops of Django - Deployment
Two scoops of Django - Deployment
 
Working with the django admin
Working with the django admin Working with the django admin
Working with the django admin
 
Learning django step 1
Learning django step 1Learning django step 1
Learning django step 1
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8
 
Command line 初級寶典
Command line 初級寶典Command line 初級寶典
Command line 初級寶典
 
Live Performance Effects
Live Performance EffectsLive Performance Effects
Live Performance Effects
 
Xmas
XmasXmas
Xmas
 
真蝦意外接到的Case
真蝦意外接到的Case真蝦意外接到的Case
真蝦意外接到的Case
 
Pytables
PytablesPytables
Pytables
 
Elasticsearch intro output
Elasticsearch intro outputElasticsearch intro output
Elasticsearch intro output
 
AngularJS Sharing
AngularJS SharingAngularJS Sharing
AngularJS Sharing
 
Django step0
Django step0Django step0
Django step0
 
Gitlab
GitlabGitlab
Gitlab
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師
 
Integrating tornado and webpack
Integrating tornado and webpackIntegrating tornado and webpack
Integrating tornado and webpack
 
解密解密
解密解密解密解密
解密解密
 
Django sharing
Django sharingDjango sharing
Django sharing
 

Similaire à Two scoops of django Introduction

Django Article V0
Django Article V0Django Article V0
Django Article V0
Udi Bauman
 

Similaire à Two scoops of django Introduction (20)

Django
Django Django
Django
 
Django
DjangoDjango
Django
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
 
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdfDjango Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
 
Django Article V0
Django Article V0Django Article V0
Django Article V0
 
Master Python.pdf
Master Python.pdfMaster Python.pdf
Master Python.pdf
 
Learn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for DevelopersLearn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for Developers
 
Master Python.pdf
Master Python.pdfMaster Python.pdf
Master Python.pdf
 
5 Effective Tips to Learn Python Fast.pptx
5 Effective Tips to Learn Python Fast.pptx5 Effective Tips to Learn Python Fast.pptx
5 Effective Tips to Learn Python Fast.pptx
 
Django Introdcution
Django IntrodcutionDjango Introdcution
Django Introdcution
 
Golang, Python or C/C++, who wins
Golang, Python or C/C++, who wins Golang, Python or C/C++, who wins
Golang, Python or C/C++, who wins
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
Why Django is The Go-To Framework For Python.pdf
Why Django is The Go-To Framework For Python.pdfWhy Django is The Go-To Framework For Python.pdf
Why Django is The Go-To Framework For Python.pdf
 
Skills and Responsibilities of a Python Developer.pdf
Skills and Responsibilities of a Python Developer.pdfSkills and Responsibilities of a Python Developer.pdf
Skills and Responsibilities of a Python Developer.pdf
 
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
What is Django | Django Tutorial for Beginners | Python Django Training | Edu...
 
Title_ Django_ Advantages, Limitations, and its Leading Edge in the Competiti...
Title_ Django_ Advantages, Limitations, and its Leading Edge in the Competiti...Title_ Django_ Advantages, Limitations, and its Leading Edge in the Competiti...
Title_ Django_ Advantages, Limitations, and its Leading Edge in the Competiti...
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to django
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| Edureka
 
Ways To Become A Good Python Developer
Ways To Become A Good Python DeveloperWays To Become A Good Python Developer
Ways To Become A Good Python Developer
 
python.pdf
python.pdfpython.pdf
python.pdf
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Two scoops of django Introduction

  • 1. Two Scoops of Django Michelle Leu | 2013/10/29
  • 2. About the Authors DjangoPackages.com the OpenComparison framework. We ran the largest sprint at PyCon 2011. PyLadies a women‟s outreach/mentorship group. Nurturing the group was basically a 2nd fulltime job for us in 2011. The first ever PyCon Philippines, a 300-person conference about the Python programming language held in the Philippines. LA Open Source Hackathon event series, which brings together open-source developers from different programming backgrounds. Audrey Roy Daniel Greenfeld
  • 3. Before You Start Buy the e-book bundle for $17 Buy the print version for $29.95 If you are new to Django …… Python programming language Python 2.7.x Buy the e-book bundle for $17 Django tutorial: https://docs.djangoproject.com/en /1.5/intro/tutorial01/. Django 1.5
  • 4. Core Concepts • • • • Simplicity is the ultimate sophistication. Fat Models, Helper Modules, Thin Views, Stupid Templates Start With Django by Default Stand on the Shoulders of Giants
  • 5. Make Your Code Readable • • • • Avoid abbreviating variable names. Write out your function argument names. Document your classes and methods. Refactor repeated lines of code into reusable functions or methods.
  • 6. PEP8 • Style Guide for Python Code  “Use 4 spaces per indentation level.”  “Separate top-level function and class definitions with two blank lines.”  “Method definitions inside a class are separated by a single blank line.”
  • 7. The Word on Imports Marketing Standard library Training Core Django Assesment Third-party apps Technology Your apps Ex: math Import from django Plugins Imports from the apps that you created as part of your Django project.
  • 8. The Word on Imports
  • 10. Avoid Using Import * • • The reason for this is to avoid implicitly loading all of another Python module‟s locals into and over our current module‟s namespace, which can produce unpredictable and sometimes catastrophic results. Python Naming Collisions
  • 11. Django Coding Style Guidelines • • Use underscores (the „_‟ character) in URL pattern names rather than dashes as this is friendlier to more IDEs and text editors. Note that we are referring to the name argument of url() here, not the actual URL typed into the browser. Dashes in actual URLs are fine. For the same reason, use underscores rather than dashes in template block names.
  • 12. Reference • Two Scoops of Django:https://django.2scoops.org/ • PEP 8 coding conventions: http://www.python.org/dev/peps/pep-0008/ • Django Coding Style Guidelines:https://docs.djangoproject.com/en/1.5/internals/con tributing/writing-code/coding-style/ Conclusion Projects with varying styles are much harder to maintain, slowing development and increasing the chances of developer mistakes.
  • 13. Thanks for your listening Michelle Leu flywindy2002@gmail.com Twitter: @flywindy Developer @ Brand Karma