elfs: (Default)
[personal profile] elfs

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

Date: 2008-10-22 07:32 pm (UTC)
From: [identity profile] duskwuff.livejournal.com
You can check out a local copy of the tutorial (and all the other online docs) from their SVN (http://code.djangoproject.com/svn/django/trunk/docs/), incidentally.

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 30th, 2025 06:34 pm
Powered by Dreamwidth Studios