I've been using arguments provided in the path(...) in urls.py for my view, which is a TemplateView.
Now, I've been trying to do the same with a similar template, but using a CreateView. After some debugging, I've realized that for some reason a CreateView doesn't seem to receive the kwargs defined in the urls.py path. For instance:
urls.py
path('product/<int:pk>/', views.SomeViewClass.as_view(), {"foo": "bar"}, name='detail_product', ),
views.py
class SomeViewClass(TemplateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
section = kwargs["foo"]
The above works. However, this doesn't:
urls.py
path('create/', views.OtherClassView.as_view(), {"foo": "bar"}, name='create'),
views.py
class OtherClassView(CreateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
section = kwargs["foo"]
Any obvious workaround? Other than fishing out this parameter through a completely different pipeline?