Django permission inheritance problem and Meta

断了今生、忘了曾经 提交于 2019-12-11 05:31:42

问题


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

回答1:


http://docs.djangoproject.com/en/dev/topics/db/models/#meta-inheritance




回答2:


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

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



来源:https://stackoverflow.com/questions/5424262/django-permission-inheritance-problem-and-meta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!