Created
July 21, 2018 18:44
-
-
Save KalobTaulien/7502cdd33ba6ff1470dfdb4542e64a9a to your computer and use it in GitHub Desktop.
Wagtail 2: Adding custom context to your pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block content %} | |
<h2>Hello world!</h2> | |
<p>{{ extra }}</p> | |
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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