On Sun, 2008-12-14 at 15:43 -0800, sajal wrote:
> when using Multi-table inheritance, how do i know what type is the
> child?

Add a child_type field explicitly to the parent model and set it during
the save() method. That will save on database queries. You could also
just try to access the child attribute ("article", "image", etc), but
that will cause one database query to be executed each time.

Django doesn't automatically add any such type field for you, since that
would prevent subclassing third-party models (you don't necessarily have
permission to alter their tables, and shouldn't do so anyway, as a
rule). If you're in complete control of the parent model, set it up to
suit your requirements.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to