code from the Lightweight Django book