Opened 12 years ago

Closed 12 years ago

#20258 closed Uncategorized (invalid)

"managed" attr of Model meta class losted during inheritance from abstract model

Reported by: vsafronovich Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class A(models.Model):
    class Meta:
        abstract = True
        managed = False

class B(A):
    pass
>>> B._meta.managed
True

must be False.

This needed for example for creating base model class for Models from legacy database.

Change History (2)

comment:1 by vsafronovich, 12 years ago

more correct example code

class A(models.Model):
    class Meta:
        abstract = True
        managed = False

class B(A):
    pass

class C(A):
    class Meta:
        db_table = 'ccc' 
>>> B._meta.managed
False
>>> C._meta.managed
True

comment:2 by Ramiro Morales, 12 years ago

Resolution: invalid
Status: newclosed

To achieve that, make C's inner Meta class inherit from A's one::

class C(A):
    class Meta(A.Meta):
        db_table = 'ccc' 

See https://docs.djangoproject.com/en/dev/topics/db/models/#meta-inheritance

Note: See TracTickets for help on using tickets.
Back to Top