Sessions at PyCon US 2012 about Django

Your current filters are…

Wednesday 7th March 2012

  • Introduction to Django

    by Chander Ganesan

    The Django framework is a fast, flexible, easy to learn, and easy to use framework for designing and deploying web sites and services using Python. In this session, we'll cover the fundamentals of development with Django, generate a Django data model, and put together a simple web site using the framework.

    • Detailed Tutorial Outline
    • Django Overview and Basic Introduction
    • Downloading & Installing Django
    • Creating a new project
    • Choosing a database
    • Creating a new application
    • Installing & Using Django contrib applications
    • Overview of Django flow (i.e., URLconf expression, view function, HTTPResponse object, etc.)
    • Generating Simple Django Views
    • Configuring a URLConf for basic views
    • Creating Django Templates (template syntax, common filters and tags, loops, etc)
    • Creating & using Template Context objects
    • Introduction to Django Models
    • Defining basic Django models
    • Understanding basic model fields & options
    • Generating & Reviewing Model SQL
    • Adding data to a model
    • Simple data retrieval using models
    • Working with QuerySets (filters, slicing, ordering, common methods)
    • Overview of Q objects)
    • Using the Admin interface
    • Using Generic views
    • Access control with sessions & users

    At 9:00am to 12:20pm, Wednesday 7th March

    In H3, Santa Clara Convention Center

  • Django in Depth

    by James Bennett

    A tutorial that goes beyond all other Django tutorials; we'll dive deep into the guts of the framework, and learn how each commonly-used component -- ORM, templates, HTTP handling, views and the admin -- work from the bottom up, covering both public and internal APIs in excruciating detail.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In D1, Santa Clara Convention Center

Friday 9th March 2012

  • PBS KIDS: Building a login system for kids and teens in Python

    by Edgar Roman

    Our challenge was to create a login system for little people who might barely read, maybe no email, perhaps no home computer. And we had to watch out for privacy laws - especially tough for minors. But these kids want to play games, write stories, and create online avatars to share and compete against their buddies. Listen to how we developed the PBS KIDS login and moderation system in Django.

    At 10:50am to 11:30am, Friday 9th March

    In E1, Santa Clara Convention Center

Saturday 10th March 2012

  • Django Templating: More Than Just Blocks

    by Christine Cheung

    Django's template language is designed to strike a balance between power and ease of use; learn how to use this balance to create awesome looking websites. This talk will cover the basics and best practices of Django templating, from custom tag and filter creation, to the finer points of template rendering and loading, and even to replacing the default templating engine itself.

    Harness the power of Django templates to help present your data with ease! Learn about:
    Basic block formations, common patterns, and using includes wisely.
    Tips and tricks in using the built-in template tags and filters.
    How to make custom tags and filters: examples, what you should and shouldn’t do, and tools to help the process such as django-classy-tags.
    Different ways to load and render templates.
    Replacing Django’s default template language: pros and cons

    At 10:25am to 11:05am, Saturday 10th March

    In E4, Santa Clara Convention Center

  • Django Form Processing Deep Dive

    by Nathan Yergler

    Django Form processing often takes a back seat to flashier, more visible parts of the framework. But Django forms, fully leveraged, can help developers be more productive and write more cohesive code. This talk will dive deep into the stock Django forms package, as well as discuss a strategy for abstracting validation for forms, and the use of unit and integration tests with forms.

    Django Form processing often takes a back seat to flashier, more visible parts of the framework. But Django forms are an integral part of the framework that can help developers be more productive and write more cohesive, well tested code. This talk will dive deep into the stock Django forms package, providing an examples of:

    • custom validation and validation patterns
    • processing multiple forms at once (form sets)
    • persisting validated form data to models (model forms)

    We'll also discuss ways to build on Django forms, including:

    * writing unit and integration tests for forms, and how writing tests can help you understand code cohesion
    & abstracting validation for forms to provide tiered validation (for example, one set of criteria to save, additional criteria to publish)
    * approaches to working with multiple, heterogeneous forms simultaneously

    At 11:05am to 11:45am, Saturday 10th March

    In E4, Santa Clara Convention Center

  • Testing and Django

    by Carl Meyer

    A deep dive into writing tests with Django, covering Django's custom test-suite-runner and the testing utilities in Django, what all they actually do, how you should and shouldn't use them (and some you shouldn't use at all!). Also, guidelines for writing good tests (with or without Django), and my least favorite things about testing in Django (and how I'd like to fix them).

    Django has a fair bit of custom test code: a custom TestSuiteRunner, custom TestCase subclasses, some test-only monkeypatches to core Django code, and a raft of testing utilities. I'll cover as much of that code as I find interesting and non-trivial, taking a close look at what it's actually doing and what that means for your tests.

    This will be a highly opinionated talk. There are some things in Django's test code I really don't like; I'll talk about why, and how I'd like to see them changed. As a natural part of this, I'll also be outlining some principles I try to follow for writing effective and maintainable tests, and note where Django makes it easy or hard.

    This is an "extreme" talk, so I'll be assuming you've used Django and done some testing, and you're familiar with the basic concepts of each. This won't be an introductory "testing with Django" howto.

    At 11:45am to 12:30pm, Saturday 10th March

    In E4, Santa Clara Convention Center

  • RESTful APIs With Tastypie

    by Daniel Lindsley

    Providing full-featured REST APIs is an increasingly popular request. Tastypie allows you to easily implement a customizable REST API for your Python or Django applications.

    Who am I? (Primary author of Tastypie)
    Why REST?
    A touch of philosophy

    Use HTTP the best we can
    Flexible serialization (not everyone wants JSON)
    What you can GET should be able to be POST/PUT
    Should be reasonable by default but easy to extend
    URIs Everywhere!
    Why Tastypie?

    Works with Django
    Any data source (Not just ORM)
    Designed to be extensible
    Supports a variety of serialization formats (JSON/XML/YAML/bplist)
    URIs everywhere by default
    Lots of hooks for customization
    Demonstrate a simple setup

    Then explore the API based on that trivial setup
    Demonstrate adding authentication/authorization

    Demonstrate adding custom serialization
    Demonstrate adding a different data source
    Demonstrate adding a custom endpoint

    At 2:15pm to 2:55pm, Saturday 10th March

    In E4, Santa Clara Convention Center

  • Cache Rules Everything Around Me

    by Noah Silas and Jacob Burch

    This talk aims to briefly introduce the core concepts of caching and covers the best practices of implementing them, using a small variety of python web frameworks (Flask, Django) for example code.

    "Are you caching?" is a question asked early on in any yarn on web scaling advice. These conversations are much better steered by asking a more open and difficult questions "What is your caching strategy?" and “How are you implementing it?” This talk aims to briefly introduce the core concepts of caching and quickly moves to cover the best practices using Django and Flask for example code. We will let the audience know what the important questions to ask are, give them advice on how to implement the right answers, and when even the built-in core backend isn’t enough, point them to more advanced techniques and the right third party tools.

    Important questions covered:

    • Why am I caching in the first place? Do I have to?
    • What is your caching strategy?
    • What are examples of good caching strategies?
    • Where do I put my cache code?
    • How dynamic is my content? Could I use a published cache?
    • Should I cache Python objects/classes, or base Python types?

    At 2:55pm to 3:40pm, Saturday 10th March

    In D5, Santa Clara Convention Center

    Coverage video

Sunday 11th March 2012

  • Improving Documentation with "Beginner's Mind" (or: Fixing the Django Tutorial)

    by Karen Rustad

    This talk evaluates a well-known free software tutorial (the official Django tutorial) from the perspective of a web development novice in order to point out omissions and common sticking points and suggest improvements. More generally, this talk is useful to anyone looking to improve their project's tutorials and other newcomer-targeted documentation by approaching them with "beginner's mind".

    Most free software projects make large, unstated assumptions about the background knowledge and experience of newcomers. Because the people who typically write tutorials or setup documentation for a project are veteran developers intimately familiar with the particulars of the project, it is unfortunately easy to gloss over material or forget the sorts of things that are likely to confuse or turn off newcomers. (How many free software projects assume that newcomers have expertise in bash, or previous experience in distributed version control, or knowledge of how to write a good bug report?) Left to their own devices, everyone designs for people like themselves--not just in software or design, but in documentation as well!

    The solution to this problem is twofold: one, ideally, to "user test" one's entry-level documentation by watching a newcomer attempt to use it and note where they get stuck; and two, more generally, to remember what it was like to be a beginning programmer and/or to make your first free software contribution and accordingly to intentionally cultivate empathy for and consciousness of that state of being.

    For this talk, we will take as an example the official Django tutorial. Django as a project has a reputation for prioritizing having high-quality and complete documentation far higher than many other FOSS projects. However, despite this high prioritization, even Django's tutorial has significant issues in terms of how well it serves new web programmers; it is primarily targeted as experienced web developers and operates better as an advertisement rather than as a how-to. As a result, it misrepresents or omits entirely whole swaths of knowledge which would be key to a newer web developer actually succeeding with Django.

    In this talk, we use the perspective of a web development novice to go through the official Django tutorial, point out omissions and common sticking points, and suggest ways to improve.

    Our hypothetical newcomer
    Imagine a novice programmer--let's say, a CS undergraduate--coming to the Django tutorial for the first time
    Fluent in Python and perhaps a couple other languages
    New to web programming
    Little experience reusing other people's code
    Lots of experience using web applications, some sense of their user-facing capabilities
    No direct experience using SQL / databases
    Critical look at the Django tutorial
    Missing concepts

    Projects vs. apps: "what's the difference, and why do I care?"
    Relatedly, reusing other people's apps -- resources and best practices
    Test driven development -- "what's this tests.py thing for?"
    Missing features

    The biggest "gotcha": handling database schema changes (aka "What do you mean I can't edit my models anymore?")
    HOWTO debug -- "what do I do when something goes wrong?"
    User-facing CRUD -- Tutorial emphasizes built-in admin, but most modern web apps focus on user-generated content instead; "how do I do that in Django?"
    Static file handling and template inheritance -- what would a "Django for designers" guide look like?
    Assumed knowledge

    HOWTO install Django safely (e.g., virtualenv)
    HOWTO deploy to an actual server (even "just" a hosted cloud solution like heroku or ep.io) -- aka "How do I show off this cool app I made to my friends?"
    Historical perspective on why the tutorial is this way
    In 2005, Django's audience was mostly intermediate-to-advanced programmers who were familiar with older, more minimal Python web frameworks
    Django was originally developed for newspapers, hence the admin app emphasis
    Remember, and be empathetic to, the kinds of mistakes you used to make before you became an experienced coder. Don't remember? Find someone who does!
    Link to third-party add-ons that improve the project (e.g., South for migrations)
    Be aware of your dependencies -- not just technical ones, but knowledge ones as well
    And link to third-party tutorials or other resources that teach those well! (e.g. debugging tools, deployment info)
    A tutorial can't cover everything, but it can at least mention nearly everything, with links for further details. A newbie doesn't know an important aspect of your framework exists unless you tell them--blind searching doesn't work very well.
    Know who you are writing for -- and say so.

    At 1:30pm to 2:10pm, Sunday 11th March

    In E2, Santa Clara Convention Center