Django permission inheritance problem and Meta

2019-08-05 15:53发布

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

2条回答
在下西门庆
2楼-- · 2019-08-05 16:26

In my case explicitly inheriting the Meta didn't work because of South. See this ticket.

django-admin.py syncdb --all fixed the problem.

查看更多
登录 后发表回答