[Answered ]-Access current page from inside a block, inside a StreamField

2👍

This isn’t possible using the current method of rendering blocks through {{ ... }} tags, because Django doesn’t pass on the context at that point. (Essentially, you’re rendering a fixed HTML representation of the block, which knows nothing about the calling page.) The only current workaround is to avoid the use of block templates for anything that needs access to the outer context, and just loop over the stream values in the outer template instead.

There’s a proposal in progress to introduce an {% include_block %} template tag, which would address this: https://github.com/torchbox/wagtail/issues/1743

👤gasman

Leave a comment