Skip to content

Commit

Permalink
Ensure routes are building from the active locale
Browse files Browse the repository at this point in the history
  • Loading branch information
robdivincenzo committed Jun 14, 2024
1 parent d066a7c commit f671d07
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions network-api/networkapi/wagtailpages/templatetags/blog_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django import template
from wagtail.models import Locale

register = template.Library()

Expand All @@ -7,10 +8,11 @@
def get_root_or_page(context):
root = context.get("root", None)
page = context.get("page", None)
locale = Locale.get_active()

if root:
return root.specific
return root.get_translation_or_none(locale).specific
elif page:
return page.get_parent().specific
return page.get_translation_or_none(locale).get_parent().specific
else:
print("There is no root or page in templatetag get_root_or_page")

0 comments on commit f671d07

Please sign in to comment.