From d1db7e5c0857647fb697805f20c4a94be22bc9dc Mon Sep 17 00:00:00 2001 From: Alex Bridge Date: Fri, 10 Sep 2021 18:10:07 +0100 Subject: [PATCH 1/2] Only attempt to add footnotes if the context's 'page' is a Page object --- wagtail_footnotes/blocks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wagtail_footnotes/blocks.py b/wagtail_footnotes/blocks.py index 7ca8645..1d990bd 100644 --- a/wagtail_footnotes/blocks.py +++ b/wagtail_footnotes/blocks.py @@ -3,6 +3,7 @@ from django.core.exceptions import ValidationError from django.utils.safestring import mark_safe from wagtail.core.blocks import RichTextBlock +from wagtail.core.models import Page FIND_FOOTNOTE_TAG = re.compile(r'.*?') @@ -29,7 +30,7 @@ def replace_footnote_tags(self, value, html, context=None): else: new_context = self.get_context(value, parent_context=dict(context)) - if "page" not in new_context: + if "page" not in new_context or not isinstance(new_context["page"], Page): return html page = new_context["page"] From 7fd7ae97c6efc56e8d88e3bb2b9327aaf5a212e8 Mon Sep 17 00:00:00 2001 From: Cameron Lamb Date: Wed, 15 Sep 2021 11:04:04 +0100 Subject: [PATCH 2/2] Update wagtail_footnotes/blocks.py Co-authored-by: Dan Braghis --- wagtail_footnotes/blocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtail_footnotes/blocks.py b/wagtail_footnotes/blocks.py index 1d990bd..b8e4be1 100644 --- a/wagtail_footnotes/blocks.py +++ b/wagtail_footnotes/blocks.py @@ -30,7 +30,7 @@ def replace_footnote_tags(self, value, html, context=None): else: new_context = self.get_context(value, parent_context=dict(context)) - if "page" not in new_context or not isinstance(new_context["page"], Page): + if not isinstance(new_context.get("page"), Page): return html page = new_context["page"]