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

Abstract intermediary class

Open mcosti opened this issue 1 year ago • 2 comments

HI!

I've just read the issue here:

https://github.com/craigds/django-typed-models/issues/61

And it seems I am running into the same kind of problem.

I would like to achieve the following structure.

class BaseClass(TypedModel):
    a = models.CharField(...)


class BaseClassWithFlavor(BaseClass):
    class Meta:
        abstract = True

    b = models.CharField(...)



class Child1(BaseClassWithFlavor):
    pass


class Child2(BaseClassWithFlavor):
    pass

Which would result in both Child1 and Child2 having the "b" field.

Is that possible in anyway?

mcosti avatar Jan 17 '24 13:01 mcosti

Thanks for the issue. This should work already I think, since it's the same situation as Child1 and Child2 both having an identical b field defined. And per the readme:

Fields defined on subclasses can only be defined on one subclass, unless the duplicate fields are exactly identical.

Presumably it's not working? Can you paste any error information you have?

craigds avatar Jan 18 '24 06:01 craigds

Hi @craigds, thanks for the answer.

TypeError: Abstract base class containing model fields not permitted for proxy model 'Child1'.

This is the error that I get

mcosti avatar Jan 18 '24 08:01 mcosti