Wagtail 块:在覆盖的 get_context 中访问上下文和请求

Mik*_*son 3 python django wagtail

我试图从上下文中获取页面和请求,以便能够在块内使用分页。我得到的唯一上下文是

上下文{'self':无,'值':无}

甚至可以在流场块内进行分页吗?

class CustomStaticBlock(blocks.StaticBlock):


    def get_context(self, value):
        context = super(CustomStaticBlock, self).get_context(value)
Run Code Online (Sandbox Code Playgroud)

渲染

{% include_block block%}
Run Code Online (Sandbox Code Playgroud)

Fra*_*ant 5

它现在正在工作(在 内get_context)。如果有人对 a 有同样的问题StreamField,请确保将其呈现为:

{% for block in page.body %} {% include_block block %} {% endfor %}

以下将不起作用(空parent_context):

{% include_block page.body %}

{{ page.body|safe }}