django-typed-models icon indicating copy to clipboard operation
django-typed-models copied to clipboard

abstract base class supported?

Open guettli opened this issue 10 years ago • 4 comments

I tried to use an AbstractBase class which uses TypedModel, but this fails:

class AbstractBase(typedmodels.TypedModel):

    class Meta:
        abstract=True
  File "/home/foo_eins_dtg/src/foo/foo/models/config.py", line 64, in <module>
    class AbstractBase(typedmodels.TypedModel):
  File "/home/foo_eins_dtg/lib/python2.7/site-packages/typedmodels/models.py", line 231, in __new__
    if not cls._default_manager:
AttributeError: type object 'AbstractBase' has no attribute '_default_manager'

Is this supported?

All models which inherit from this AbstractBase should have each its own table.

guettli avatar Jul 10 '14 12:07 guettli

Same issue here. Any updates?

ccdavid avatar Jan 23 '15 05:01 ccdavid

This is a limitation on django itself. Whenever you create an abstract model only its subclasses have access to the manager (.objects) due to the fact that the model does not have a table, so you can't access the full set of instances like in multi-table inheritance, where parent has a table and maps the childs with an one to one relationship.

cdvv7788 avatar Jan 29 '15 19:01 cdvv7788

I too, like guetti, expected this to work. Wouldn't this be a nice feature?

JVanloofsvelt avatar Apr 27 '16 08:04 JVanloofsvelt

👍 for this feature

tom-zeit avatar Jul 01 '16 10:07 tom-zeit