我是FeinCMS的新手,我正尝试创建自己的内容类型。这使用我创建的另一个自定义内容类型。FeinCMS管理员内嵌
在下面的代码中,“CollapsiblePanel”未显示在管理员中,因为我只希望您能够从ContentBox部分创建“CollapsiblePanels”。
您也可以为每个ContentBox创建多个CollapsiblePanel。我无法搞清楚如何把这个在一起,使管理员可以让你添加ContentBox
class CollapsiblePanel(models.Model):
title = models.CharField(max_length=255)
content = models.TextField()
def render(self, **kwargs):
return render_to_string('collapsiblepanel.django.html', {
'media': self,
'title': mark_safe(self.title),
'text': mark_safe(self.content),
})
class ContentBoxMedia(RichTextContent):
title = models.CharField(_('title'), max_length=200, blank=True)
collapsible = models.BooleanField()
collapsiblePanels = models.ForeignKey(CollapsiblePanel)
class Meta:
abstract = True
verbose_name = 'Content Box'
verbose_name_plural = 'Content Box'
def render(self, **kwargs):
return render_to_string('contentbox.django.html', {
'media': self,
'title': mark_safe(self.title),
'text': mark_safe(self.text),
})
看来这个代码有两个问题。首先,CollapsiblePanel的ForeignKey可能是错误的 - 它应该是从你的描述中判断的另一种方式。其次,不能使用内联内联进行编辑 - 股票Django不允许这样做,因此FeinCMS也没有。 – 2011-03-26 20:18:17
哈哈;正如我刚才在我的回答中解释的那样... Hi Matthias :) – DrMeers 2011-03-26 20:37:37