I have the following code
---- urls.py ----
url(r'^(?P<city_slug>[-\w]+)/$',
BookingWizard.as_view(),
name='city_booking'),
---- views.py ----
class BookingWizard(SessionWizardView):
def get_context_data(self, form, **kwargs):
context = super(BookingWizard, self).get_context_data(form, **kwargs)
cities = City.objects.all()
context.update({'cities': cities,
'city': City.objects.get(slug=kwargs['city_slug'])})
return context
The problem is I'm getting key error trying to access kwargs['city_slug']
in the get_context_data()
method.
although I can access kwargs['city_slug']
in the done()
method with no problems.
Any ideas?