On 4 March 2011 17:03, Craig de Stigter <craig...@gmail.com> wrote: > Hi guys > > Thanks for pointing those out. I knew I couldn't have been the first to want > this. I guess I just didn't know the right words to search for here. > It looks like django_polymorphic does what I want. I'm not yet sure why it > says it takes one query per type of model in a queryset. Unless it is > talking about multi-table inheritance, in which each type would require a > different join. But I'll look in more detail in the next few days and no > doubt it will become clear.
+1 for better polymorphic support in Django core; it is a very common problem which could do with an efficient and elegant solution. Regarding efficiency, if you can keep track of your subclasses effectively (potentially using a registry if not introspection), you can use select_related to retrieve heterogeneous multi-table inheritance models in a single query (see example in [1]). I haven't looked deeply enough into django_polymorphic to see if it includes such optimisations. I'm sure we could further tweak the internals to make things more efficient and developer-friendly in this regard. Cheers, Simon [1] http://stackoverflow.com/q/5175009/284164 -- 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.