Real world Python+django

Post on 19-Jun-2015

356 views 4 download

Tags:

transcript

Real world

Joel Correa – Software engineer

\ There are some ordinary

topics…

View

ORM Admin interface

URL design

Template

Model

I18n

Function-based views

But, guess what… There is much more

Class-based views (CBVs)

View RedirectView

TemplateView

ListView

DetailView

CreateView

UpdateView

Class-based views

Fixtures

JSON SQL

Fixtures

OK for very small, hard-coded datasets

NOK for large datasets, and migrations

Fixtures

OK for very small, hard-coded datasets

NOK for large datasets, and migrations

Fixtures

Schema migration Data migration

Validating user input

Model

Form

Formset

Input validation layers

Use pip

Managing packages

$ pip install SomePackage==1.0!![…]!Successfully installed SomePackage!!

Set up a virtualenv

$ virtualenv env!$ source env/bin/activate!!

$ pip freeze!!Django == 1.5.4!Fabric == 1.7.0!MySQL-python == 1.2.4!PIL == 1.1.7!PyRSS2Gen == 1.0.0!South == 0.8.1!

Isolate environments

Check your deps

$ pip freeze > requirements.txt!

Freeze your deps

$ pip install –r requirements.txt!

Recreate env

Coding style = PEP8 http://www.python.org/dev/peps/pep-0008/

Code layout

Comments

Naming conventions

Programming conventions

Public and internal interfaces

Coding style = PEP8 http://www.python.org/dev/peps/pep-0008/

Celery

Distributed task Queue

Amazon SQS

RabbitMQ

IronMQ

Real world

Joel Correa – Software engineer