문제

I understand Meta can be inherited if the superclass has abstract=True, but can't be inherited otherwise. Is this because Django somehow consumes and removes the Meta class from concrete classes? I'd like to do something as in the example below, so Derived can get the Meta properties from Base (in this case, to inherit permissions as part of django-guardian).

Suggestions on how to achieve this would be appreciated.

Ian

class Base(Model):
    class Meta:
        permissions = (("foo", "Allowed to do foo"),)

class Derived(Base):
    class Meta(Base.Meta): pass

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top