Skip to content

Instantly share code, notes, and snippets.

@KalobTaulien
Created July 21, 2018 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KalobTaulien/7502cdd33ba6ff1470dfdb4542e64a9a to your computer and use it in GitHub Desktop.
Save KalobTaulien/7502cdd33ba6ff1470dfdb4542e64a9a to your computer and use it in GitHub Desktop.
Wagtail 2: Adding custom context to your pages.
{% extends 'base.html' %}
{% block content %}
<h2>Hello world!</h2>
<p>{{ extra }}</p>
{% endblock content %}
from wagtail.core.models import Page
class YourPage(Page):
"""Your Wagtail Page Type."""
template = "templates/your_page.html"
def get_context(self, request, *args, **kwargs):
"""Provide additional context information."""
context = super().get_context(request)
context['extra'] = 'Read all about it!'
return context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment