On Thu, 2008-11-27 at 15:11 -0800, Chris Smith wrote:
> Hi,
> 
> I'm using Django 1.0.2, psycopg2 and PgSQL 8.3 on Ubuntu...
> 
> I've created a models.py with the following structure to represent a
> "party model".  The target for this is a simple CRM system.
> Structure:
> 
> class Party(models.Model):
>       class Meta:
>               abstract = True
> 
> class Organisation(Party):
>       name = models.CharField(max_length=100)
> 
> class Person(Party):
>       first_name = models.CharField(max_length=50)
>       last_name = models.CharField(max_length=50)
> 
> This generates two tables (product_organisation + product_person) when
> I run syncdb.  According to This Week In Django [1], it states that
> the model would be flattened into a single table inheritance model [2]
> but it doesn't do this.

When in doubt, check the documentation. Brian and Michael put a lot of
effort into their show, but sometimes they and the people they're
talking to make mistakes or slip in an ambiguous word. Spoken language
is much more susceptible to that than written and edited documentation.
That may have been the case here.

Django's usage follows the same meaning of 'abstract' as class
inheritance in many OO languages: abstract classes can't stand on their
own and are tightly associated with their descendent instances. The
Person and Party models are flattened into the a single table. The
Organisation model is entirely unrelated to the Person model and is not
part of the same table. In other words, all the abstract ancestors are
flattened into the child model's table. Sibling classes are not
flattened into the same table.

Non-abstract inheritance (the comparison point) would result in three
tables (one for each parent -- which is only one, since it's a common
parent -- and one for each child).

> 
> From experience with other ORM platforms (nHibernate, custom built),
> I'd expect this to flatten out to a table with approximately the
> structure:

Assumptions frequently lead us astray. There are various meanings that
can be assigned to various words and you have guessed differently from
the Django usage. 

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 [email protected]
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