I have a form in which the value of the first field can be determined by the URL. ie: example.com/value/form
in which value
is the appropriate response to the first field on the form.
How can I pass this value to the form on the page?
class VarietyCreate(CreateView):
template_name = "generic_create.html"
model = Variety
form_class = VarietyForm
pk_url_kwarg = "pk"
initial = {"product_group" : pk_url_kwarg}
def get_success_url(self):
return reverse("purchases:Variety Index", kwargs={'pk': self.kwargs.get('pk')})
What I have does not seem to work.
From my URLs:
url(r'^commodities/view/(?P<pk>[^\/]+)/create/$', views.VarietyCreate.as_view(), name='Variety Create'),