继承模型元类的正确语法是什么。
我试过这个:
型号:
class something(Base)
etc
class Meta(*args, **kwargs):
super(something).__init__(*args, **kwargs)
ordering = ('created',)
class base(models.Model):
class Meta:
abstract = True
app_label = "someApp"
答案 0 :(得分:3)
此特定情况在文档中的Meta inheritance
段落中进行了描述。
定义abstract
模型并从中继承其他模型,Meta
也应该从抽象模型Meta
类继承:
from django.db import models
class Base(models.Model):
class Meta:
abstract = True
app_label = "someApp"
class Something(Base):
# ...
class Meta(Base.Meta):
ordering = ('created',)