[Answered ]-Django abstract model inheritance

3👍

Not sure if it is the prettiest way in town but this should work:

while self.__class__.objects.filter(...):
    pass

-1👍

When you create SomeModel(SomeAbstractModel), just create the class Meta from scratch without inheriting. By inheriting vom SomeAbstractModel.Meta you make it abstract again, and you cannot query on abstract model, not because they have no manager, but because there are no tables created.

So either you do this:

class SomeModel(SomeAbstractModel):
    ...
    class Meta(SomeAbstractModel.Meta):
        abstract=False
        ... your other model specific options

Or you do this (if you do not have any other model specific options:

class SomeModel(SomeAbstractModel):
    ...

Leave a comment