Created
March 7, 2018 10:03
-
-
Save stuaxo/5226ddc1e66e8c5fea78e76b5909b7c8 to your computer and use it in GitHub Desktop.
Wagtail FormViewPage
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
class FormViewPage(Page): | |
""" | |
Allow a wagtail Page to render a FormView. | |
""" | |
def __init__(self, view, *args, **kwargs): | |
self.view = view | |
Page.__init__(self, *args, **kwargs) | |
def serve(self, request): | |
""" | |
Populate response with context from wagtail as well as | |
FormView | |
:param request: | |
:return: | |
""" | |
view = self.view.as_view() | |
response = view(request) | |
response.context_data['page'] = self | |
response.context_data['self'] = self | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment