two scoops of django introduction

13
Michelle Leu | 2013/10/29 Two Scoops of Django

Upload: flywindy

Post on 15-Jan-2015

503 views

Category:

Technology


1 download

DESCRIPTION

Two scoops of django Introduction and Ch1

TRANSCRIPT

Page 1: Two scoops of django Introduction

Michelle Leu | 2013/10/29

Two Scoops of Django

Page 2: Two scoops of django Introduction

DjangoPackages.comthe OpenComparison framework. We ran the largest sprint at PyCon 2011.

About the Authors

PyLadiesa 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.

Daniel GreenfeldAudrey Roy

Page 3: Two scoops of django Introduction

Buy the e-book bundle for $17

Before You Start

If you are new to Django ……

Python programming languagePython 2.7.x

Django tutorial: https://docs.djangoproject.com/en/1.5/intro/tutorial01/. Django 1.5

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

Page 4: Two scoops of django Introduction

•Simplicity is the ultimate sophistication.

•Fat Models, Helper Modules, Thin Views, Stupid Templates

•Start With Django by Default

•Stand on the Shoulders of Giants

Core Concepts

Page 5: Two scoops of django Introduction

•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. 

Make Your Code Readable

Page 6: Two scoops of django Introduction

•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.” 

PEP8

Page 7: Two scoops of django Introduction

TechnologyAssesmentTrainingMarketing

Ex: math

Standard library

Plugins

Third-party apps

Imports from the apps that you

created as part of your Django project.

Your apps

Import from django

Core Django

The Word on Imports

Page 8: Two scoops of django Introduction

The Word on Imports

Page 9: Two scoops of django Introduction

Use Explicit Relative Imports

Page 10: Two scoops of django Introduction

•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

Avoid Using Import *

Page 11: Two scoops of django Introduction

•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. 

Django Coding Style Guidelines

Page 12: Two scoops of django Introduction

Reference

ConclusionProjects with varying styles are much harder to maintain, slowing development and increasing the chances of developer mistakes.

•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/contributing/writing-code/coding-style/

Page 13: Two scoops of django Introduction

Michelle Leu

Thanks for your listening

[email protected]

Twitter: @flywindy

Developer @ Brand Karma