Skip to content

Instantly share code, notes, and snippets.

@stuaxo
Created March 7, 2018 10:03
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 stuaxo/5226ddc1e66e8c5fea78e76b5909b7c8 to your computer and use it in GitHub Desktop.
Save stuaxo/5226ddc1e66e8c5fea78e76b5909b7c8 to your computer and use it in GitHub Desktop.
Wagtail FormViewPage
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