wagtail-脚注实施麻烦

问题描述 投票:0回答:1

我尝试按照自述文件进行操作,但它在管理和前端中将脚注呈现为其 [uuid]。

博客.py

from wagtail_footnotes.blocks import RichTextBlockWithFootnotes
class BlogPage(Page):
    body = RichTextField(blank=True, features=["bold", "italic", "ol", "ul", "hr", "link", "document-link", "footnotes",])

    extras = StreamField([
        ("testimonial", SnippetChooserBlock(
            target_model='testimonials.Testimonial',
            template="streams/testimonial_block.html"
            )
        ),
        ("RichTextBlockWithFootnotes", RichTextBlockWithFootnotes(label=("RichText with Footnotes"),
                features=["bold", "italic", "ol", "ul", "hr", "link", "footnotes", "document-link"]
            )),
            ("large_image", blocks.ImageChooserBlock(
                template = "streams/large_image_block.html"
            )),
    ], null=True, blank=True, use_json_field=True)

content_panels = Page.content_panels + [
    FieldPanel('body'),
    FieldPanel("extras"),

    InlinePanel('footnotes', label="Footnotes")

我已在 blog_page.html 的 {% block content %} 开头添加了模板标签

{% block content %}
{% include "wagtail_footnotes/includes/footnotes.html" %}

我这样称呼身体: blog_page.html

{% block content %}
{% include "wagtail_footnotes/includes/footnotes.html" %}
    <div class="block-richtext">
        {{ page.body|richtext }}
    </div>
{% endblock content %}

看起来在 wagtail_footnotes/includes/footnotes.html 文件中,此部分未到达,我不知道为什么:

{% for footnote in page.footnotes_list %} 

如果我尝试:

body RichTextBlockWithFootnotes(blank=True, features=["bold", "italic", "ol", "ul", "hr", "link", "footnotes", "document-link"]) 

我收到此错误:

django.core.exceptions.FieldError:指定了未知字段(主体) 对于博客页面

我已附上一张图像,显示脚注如何在 RichTextField 正文中呈现,其中“body”作为内容,“TEST”作为脚注。

wagtail
1个回答
0
投票

RichTextField 的实现似乎不完整。您可以使用 https://github.com/torchbox/wagtail-footnotes/pull/37/files#r998749704 方法(使用自定义模板标签)作为解决方法,直到我发布此问题的修复程序

© www.soinside.com 2019 - 2024. All rights reserved.