Thursday, April 18, 2013

Re: Inheritance question: Multiple roles for users

Model inheritance is not the same as object inheritance.

If you are doing non abstract inheritance, then there is no difference
between a derived model, and a model that has a foreign key to the
parent class. In a derived model, the foreign key is a OneToOneField,
with null=False, blank=True. In other words, inheritance is exactly
the same as composition for non abstract inheritance. The main
difference is that if you inherit, the fields that are actually in the
parent table magically appear as attributes of your derived object and
all your queries involving this table require a join. Magic is bad,
extra joins are bad, magic that causes extra joins are double bad.

Tom, Many thanks for the detailed reply.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate