Hi,

I got a serious problem with model inheritance in my Django model. Here's a 
sample:

from django.db import models

class MPTTTree(models.Model):
    created_at = models.DateTimeField(_('creation date'), auto_now_add=True)
    updated_at = models.DateTimeField(_('last update date'), auto_now=True)
    parent = models.ForeignKey("self", null = True, blank = True)
    lhs = models.IntegerField(default=0, db_index = True)
    rhs = models.IntegerField(default=0, db_index = True)
    level = models.IntegerField(default=0, db_index = True)
    
class Test(MPTTTree):
    name = models.CharField(_('Name'), maxlength=255)

I can run python manage.py sql myTest and I get this result :

BEGIN;
CREATE TABLE "mytest_test" (
    "id" serial NOT NULL PRIMARY KEY,
    "created_at" timestamp with time zone NOT NULL,
    "updated_at" timestamp with time zone NOT NULL,
    "parent_id" integer NULL,
    "lhs" integer NOT NULL,
    "rhs" integer NOT NULL,
    "level" integer NOT NULL,
    "name" varchar(255) NOT NULL
);
CREATE TABLE "mytest_mptttree" (
    "id" serial NOT NULL PRIMARY KEY,
    "created_at" timestamp with time zone NOT NULL,
    "updated_at" timestamp with time zone NOT NULL,
    "parent_id" integer NULL,
    "lhs" integer NOT NULL,
    "rhs" integer NOT NULL,
    "level" integer NOT NULL
);

ALTER TABLE "mytest_test" 
        ADD CONSTRAINT 
                "parent_id_referencing_mytest_mptttree_id" FOREIGN KEY 
("parent_id")
        REFERENCES "mytest_mptttree" ("id");

ALTER TABLE "mytest_mptttree"
        ADD CONSTRAINT
                "parent_id_referencing_mytest_mptttree_id" FOREIGN KEY 
("parent_id")
        REFERENCES "mytest_mptttree" ("id");

COMMIT;

I can easely understand the second alter statment but I guess there's a little 
problem with the first one. The constraint should reference "mytest_test" and 
not "mytest_mptttree".


Any idea ??

Regards,

Laurent.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to