On Tue, Mar 29, 2011 at 2:21 PM, Carl Meyer <c...@oddbird.net> wrote: > Hi Shawn, > > What you've outlined here is certainly possible (and yes, you'd need to > subclass the ModelBase metaclass). I haven't looked at the abstract > inheritance stuff recently, but I think there would be some alternative > ways for the abstract base to know about its children that wouldn't > require the metaclass assignment. However: getting the list of > subclasses is (less than) half the battle; the trickier part is giving > the ORM the capability to do UNION queries on similar tables, so you can > get results from multiple tables in a single QuerySet.
Carl, Thanks for the explanation. That does make sense and I see where it gets really tricky when you delve into the ORM. I'm not proposing a change to Django itself or suggesting that this should be a standard practice. I do think that this is a fairly clean solution for an individual to use to solve this problem if they have it. They can create a custom manager on the abstract class that would return an iterable, perhaps using itertools.chain() of the querysets. It depends on what they expect to do with the output of this custom manager, and they'd obviously lose the ability to treat this output as a queryset by using additional sorts & filters and such. But if the goal is to be able to get instances from all subclasses at once then this is a viable solution, FWIW. Shawn -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.