tomchristie/django-vanilla-views — pull request #25 by qris (2014-05-08 12:55:36+00:00)
Title: Add view kwargs (e.g. from URL mapping) to rendering context

I was wondering what happened to the `kwargs` passed to the `get()` method.
So I checked `TemplateView` and found this:

class TemplateView(GenericView):
def get(self, request, *args, **kwargs):
context = self.get_context_data()
return self.render_to_response(context)

I.e. the kwargs are completely ignored and discarded.

How about passing them to `get_context_data` instead? Then we can write our
URLs with keyword argument placeholders:

url(r'^commitment/(?P\S+)/(?P\S+)/(?P\S+)$',
views.CommitmentComparison.as_view(), name='commitment-comparison'),

and those parameters will end up in our context, and hence available to the
template, without any extra work.