Coding Patterns in Django

Latest Changes

Sep 04 2011

New: Automatically Filling in a User in the Admin

Sometimes it is nice to automatically add the current user into a field, like to easily keep track of the last user who modified a record or automatically set the “author” of a record. In earlier versions of Django this was pretty simple, but with validation added to Django, it requires a bit more work.

Aug 30 2011

New: Introduction to Decorator Applications

A decorator app is an application that adds functionality to another application without the application's awareness. It is different than a Python decorator, rather it follows the idea from Design Patterns: Elements of Reusable Object-Oriented Software.

Aug 19 2011

New: Views as a package

This pattern allows for refactoring the view code into several files without effecting the import process in other files. In other words from coolapp.views import foo still works.

Aug 18 2011

Updated: Django Version Reporting

Updated the example script to use Stefan Foulis' PEP 386-compliant example from https://gist.github.com/1149730

Aug 13 2011

New: Configurable Applications

You want to allow configuration of your app without having to modify its code. You may also want to provide reasonable defaults that users can override.