?

Log in

No account? Create an account
entries friends calendar profile Elf Sternberg's Pendorwright Projects Previous Previous Next Next
Django: The Book Is Wrong, the Tutorial is Right - Elf M. Sternberg
elfs
elfs
Django: The Book Is Wrong, the Tutorial is Right

A couple of weeks ago I bought the book “The Definitive Guide to Django,” and I’ve come to realize, to my frustration, that the book is already outdated.  My big headache this week was dealing with the administration interface, which the Django people swear is one of the coolest features of the entire application server.  The problem is simple: between Django 0.96, which is when the book was written, and Django 1.0, which is what I’m running, the interface was completely changed.

In 0.96, the way you defined a database table as being “administratable” was to add to the Python definition of the table a subclass entry class Admin: pass.  The Administration app would automagically pick out those tables that were administratable and they would appear in the admin interface.

In 1.0, it’s completely different.  Instead, you must create in your application, next to your models, a file admin.py which contains registry lines for each model and, optionally, an administration interface class that describes how the model should be administered.  It’s all covered in the Django tutorial which doesn’t really help you if all you have is the book.

This makes obvious sense. Administrative details are independent of model details, and although the argument could be made (and was made) that they’re implementation details of the model, making it a separate decorating class also makes just as much sense. Yes, it means that the details of a class (the administrative class of a model) are in two different places, but it also means that administrative features of your application can be restricted in deployment just by deleting the admin.py file.

You did keep a copy of admin.py in your source control, right?

This entry was automatically cross-posted from Elf's technical journal, ElfSternberg.com

Tags: ,

1 comment or Leave a comment
Comments
(Deleted comment)
1 comment or Leave a comment