I am working through some of the examples from James Bennetts
"Practical Django Projects" and I have encountered a small problem.
Note that I am not describing the whole context here, so if you have
not read the book, you may find it somewhat difficult to answer.

In the blog example, we define an additional manager for the
Entry-class (called the LiveEntryManager); the purpose is to easily be
able to retrieve "live" blog entries only (and skip the ones that are
still draft or hidden, saying something like Entry.live.all()). The
examples tells us to also add a "regular" manager to the Entry class,
but to define them with the live one first, something like:

live = LiveEntryManager()
objects = models.Manager()

Now, doing it like this gives me problems in the admin interface (I am
running a fairly recent trunk), in that I cannot view (or edit)
entries that are not in the "live" state; AFAIU, the admin interface
will use the default manager, which is the first one defined, in this
case the LiveEntryManager, and thus I will only have access to live
entries in the admin.

A simple solution to this is to just reverse the order, putting the
"regular" manager first in Entry class. The problem with this is that
in a later chapter, where we write custom tags, we write a tag that is
able to handle different types of models, and you will want to use the
LiveEntryManager for Entry classes, but as the tag should be able to
handle different models, you don't know a priori that you are going to
deal with an Entry, so in order to only get the live entries in that
case, the tag relies on using the "self.model._default_manager.all()"
way of getting to the objects. And obviously, this only works if the
LiveEntryManager is defined first...

So, is there an elegant solution to this, or does it have to get ugly...?


Cheers,

johan

-- 
Johan Liseborn

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to