Wagtail Views: extra context

心已入冬 提交于 2019-11-30 20:31:28

You can do this by overriding the get_context method on your page model:

class HomePage(Page):
    def get_context(self, request):
        context = super(HomePage, self).get_context(request)
        context['forums'] = Forum.objects.all()
        return context

This makes the variable forums available on your template.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!