Django in Depth

Type:
Tutorial
Audience level:
Intermediate
Category:
Web Frameworks
March 7th 1:20 p.m. – 4:40 p.m.

Description

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.

Abstract

  • Introduction

  • So you did the official Django tutorial, and read a bunch of documentation: now what?

  • You still don't know how to customize the ORM or the admin, build complex forms, manipulate the innards of the template system, etc.; common real-world use cases where you need this stuff

  • Time to peek under the hood and see how all these bits really work

  • The ORM

  • Models, Managers, QuerySets, Queries and routers: understanding how Django turns Python method calls into database queries

  • The lowest level: database backends and routers

    • Teaching Django how to talk to your database

    • How multi-database setups work

  • The Query class

  • Understanding QuerySet

    • What really happens when you call all those query methods

    • When is a container not a container? Laziness, cloning and other things which can affect the results you see

    • Little-known, but incredibly useful built-in querying options

    • Adding new query methods by writing your own QuerySet

  • Managers

    • The basics: writing and using custom managers

    • Multiple managers, and confined query schemes

    • Hierarchies of manager classes to encapsulate query patterns

    • Tailoring custom managers and custom QuerySets to each other

  • Models

    • How the Model metaclass works

    • Customization hooks

    • The Options class and the model loading and introspection API

    • Custom model fields

    • The model instance lifecycle

  • Model-level data validation

    • Key methods

    • The validation chain

    • Limitations, and when to use model validation versus form validation

  • Model inheritance

    • Supported flavors

    • When to use each

  • The forms library

  • Forms, Fields and Widgets

    • How data is parsed and passed inside a form

    • How a form is rendered

  • Understanding the validation chain

    • Validating field contents in the field itself

    • Validating field contents in the form

    • Validating the form as a whole

  • Model-based forms

    • How a model definition is translated into a form class

    • Overriding at the form level

    • Overriding at the model field level

  • Advanced form usage

    • Class-level and instance-level customization: fields versus base_fields

    • Implementing custom logic through form constructors

    • Building a form dynamically, part 1: factory functions and closures

    • Building a form dynamically, part 2: letting Python construct types for you on the fly

  • The template system

  • The template API

    • How Django finds templates

    • Custom template loaders and alternate template systems

    • Template lifecycle

  • How a Django template is parsed

    • Template, NodeList and Node classes

    • Special cases: blocks and includes

  • Template rendering

    • What really goes on inside the Context class

    • How Nodes and NodeLists render

  • Advanced template tags

    • Accessing the template parser from inside a tag

    • Working at the level of NodeLists instead of individual Nodes

  • The request-processing pipeline

  • Understanding the HttpRequest object

  • The middleware chain

  • How Django's URL dispatcher works

  • Exception processing and customized error handling

  • The view layer

  • Callables all the way down: what a view really is

  • Class-based views

    • Inside Django's base view classes

    • How the generic views work

    • What the mixins do

    • When class-based views are appropriate

  • Chaining and composing views

    • Views which invoke views which invoke views

    • Writing and applying view decorators

  • The admin application

  • The AdminSite class

    • Dispatch within an admin site

    • Important non-model-specific views

    • How models are registered and unregistered

    • Writing and using custom AdminSite instances

  • The ModelAdmin class, part 1: overview

    • Dispatch within a specific model's admin

    • Model-specific admin views

    • How inline models are tracked

  • The ModelAdmin class, part 2: customization

    • Useful attributes of ModelAdmin

    • Annotating a model with hints for the admin

    • ModelAdmin methods for customizing permissions and authorization

    • ModelAdmin methods for customizing forms and database interaction