Saturday 12:10 p.m.–12:55 p.m.

Django: The good parts

James Bennett

Audience level:
Intermediate
Category:
Web Frameworks

Description

Lots of talks and tutorials try to cover Django exhaustively, going over every component and feature. But not so many take a look at the bits that let Django be Django. In this talk, we'll see exactly what those bits -- some old, some new -- are, in a way that shows why it's still a solid and popular choice for web developers nearly nine years after its initial public release.

Abstract

Django is nearly nine years old, and is pretty big, both in terms of user base and in terms of code. But what makes it useful? What makes it a good choice for Web development? It's not the feature list or the number of components, it's a few very important core ideas. The first is Django's core request/response life cycle and abstractions, which offer a higher-level approach over raw WSGI (even though ultimately Django itself will speak WSGI to the Web server, and will translate between Django's own request/response classes and WSGI's more CGI-like programming model). This carries over from the base request and response objects into the actual implementation of request processing: Django views are simply Python callables which take a request and either return a response or raise an exception, allowing for easy exploratory programming with a minimum of interference from the abstractions. The second is a tendency to find balance between shipping only the minimal code necessary for Web programming (as in many lighter-weight frameorks) and trying to ship *everything*. Django's core component set has remained relatively constant throughout its history, and major new features and functionality are evaluated in a very conservative fashion, with the tendency in the past few years actually being toward "un-bundling" -- functionality which used to ship with Django itself is now in the process of being spun off into separately-distributed applications -- and providing sound default implemenations which can be easily replaced with third-party versions as needed (as in the case of the template system, and authentication framework, to take two examples). This allows Django to cover common cases while leaving room for the community to grow solutions and additional functionality on top of a solid core. Finally, the concept of the Django application, as an encapsulated unit of functionality, gives developers a major advantage in code reuse and being able to easily integrate disparate functionality to compose more complex Web sites or Web applications. Django's core components essentially function as a dependency that all application developers can assume, and Django's APIs provide a common "language" all applications can speak. This helps to minimize the amount of new code developers need to write, and acts as a powerful "force multiplier": even a lone developer has the resources of the entire Django community, and the large existing base of applications and functionality, to draw on when embarking on a new project. Taken together, these ideas make Django a powerful and useful addition to a Web developer's toolbox, and allow developers of multiple experience levels to quickly and efficiently build useful, modern Web applications.