Skip to content

Commit 0a13e37

Browse files
authored
Merge pull request #21 from torchbox/fix/page-context
Only attempt to add footnotes if the context's 'page' is a Page object
2 parents 474c19d + 7fd7ae9 commit 0a13e37

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

wagtail_footnotes/blocks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.core.exceptions import ValidationError
44
from django.utils.safestring import mark_safe
55
from wagtail.core.blocks import RichTextBlock
6+
from wagtail.core.models import Page
67

78
FIND_FOOTNOTE_TAG = re.compile(r'<footnote id="(.*?)">.*?</footnote>')
89

@@ -29,7 +30,7 @@ def replace_footnote_tags(self, value, html, context=None):
2930
else:
3031
new_context = self.get_context(value, parent_context=dict(context))
3132

32-
if "page" not in new_context:
33+
if not isinstance(new_context.get("page"), Page):
3334
return html
3435

3536
page = new_context["page"]

0 commit comments

Comments
 (0)