Additional context for class based views through urlconf
I thought there was a simpler method of adding context through the urlconf but after having a look at the source this is what I came up with. Apparently there's only getcontextdata() so I used a lambda to add what I needed.
Update: I should probably have used extra_context={'model': 'Frontpage'}
url(
r'^$',
TemplateView.as_view(
template_name='pages/front.html',
get_context_data=lambda: {'model': 'Frontpage'},
),
name='front',
),
1 comment
Reply