Template Tags

Using template tags to get translations

In order to get the translation for a page model, we need to have the locale which is found in the context of a template. This can be accessed from a template tag.


Returns the translation for the page model. It gets the locale from the context and returns the translation for that locale:

get_translation(context, page)


Takes in context, a queryset and a locale. It returns all the pages in their correct locale:

get_pages(context, qs, locale)


Takes in context and a page. It renders the translated pages in wagtail CMS:

render_translations(context, page)

Using template tags to render content

Content for Home Page

The section_listing_homepage tag will return all the sections with articles in them that are featured on the homepage:


The latest_listing_homepage tag will return all the articles that are featured in latest section on the homepage:


The bannerpages tag will return all the banners that are live:


The footer_page tag will return all the footer pages that are live:


Content for Section Pages


Returns the tags that are shown in a section (amount specified by tag_count) with the articles for that tag (amount specific by tag_article_count):

get_tags_for_section(context, section, tag_count=2, tag_article_count=4)


Returns all the section that are live for a specific Main page:



Returns articles that are children of a specific section page (amount specified by count):

load_child_articles_for_section(context, section, count=5)


Returns articles that are descendants of a specific section page (amount specified by count). It is possible to specify whether these articles have to be featured in the homepage, section or latest:

        context, section, featured_in_homepage=None, featured_in_section=None,
        featured_in_latest=None, count=5)


Returns all the child sections for a specific question. The amount returned can be limited by count:

load_child_sections_for_section(context, section, count=None)

Content for Articles Pages


Returns the parent page of an article page:

get_parent(context, page)


Returns the next article in a list of articles:

get_next_article(context, article)


Returns all reaction questions that have been linked to this article:

load_reaction_question(context, article)


Returns True or False based on whether a user has already voted on this question or this article or not:

load_user_can_vote_on_reaction_question(context, question, article_pk)


Returns all the choice that are live for a reaction question:

load_choices_for_reaction_question(context, question)


Returns all the tags that have been attached to this article in the CMS:

load_tags_for_article(context, article)


Returns the social media article:


Content for Tag Pages


Returns all the articles that have been linked to a specific tag:

get_articles_for_tag(context, tag)

The get_next_tag tag returns the next tag in the list of live tags. If the current tag is the last in the list, it will return the first tag:

get_next_tag(context, tag)

Content for CMS

The should_hide_delete_button tag returns True or False based on whether a page should be deletable or not:

should_hide_delete_button(context, page)