是否有任何默认操作允许每页只允许一次内容类型,然后覆盖管理表单?文档不清楚这一点 最佳答案 我不认为有一个开箱即用的实现,你可以在
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.