简单的ag流域模板不起作用

时间:2019-06-23 19:57:11

标签: django wagtail

它是我的模板代码:

{% for post in page.get_children %}
    ONE {{ post.title }} <--- it shows correct, excepted title
    {% for block in post.body %}
      TWO <--- this is NEVER showen
    {% endfor %}
{% endfor %}

它是我的BlogIndexPage:

class BlogIndexPage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
    ])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ] 

它是我的BlogPage:

class BlogPage(Page):
    date = models.DateField(auto_now=True)
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
    categories = ParentalManyToManyField('blog.BlogCategory', blank=True)

    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
    ])

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('tags'),
            FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        ], heading="Blog information"),
        StreamFieldPanel('body'),
    ]

我只是无法访问块属性,因为post.body像空数组一样掉落(我将BlogPage作为BlogIndexPage的子项添加,并且我在StreamField中填充了一些文本,标题和图片-它不为空)

我确定我缺少明显的东西,但我自己看不到。

0 个答案:

没有答案