是否有任何默认操作允许每页只允许一次内容类型,而不是覆盖管理表单?文档不清楚这个
答案 0 :(得分:2)
我不认为这是一个开箱即用的实现,你可以在Github建议一个。由于FeinCMS内容类型是抽象的Django Model类,因此您可以使用其干净的方法,例如
class FooContent(models.Model):
content = models.Bar('...')
class Meta:
abstract = True
def clean(self):
if self.parent.foocontent_set.count() >= 1:
raise ValidationError('FooContent is only allowed once per Page.')
def render(self, **kwargs):
return render_to_string('content/foo.html', {
'content': self.content
})
这会在管理表单上引发non field error。