Formview Cbv Change Modelform Per Request
I am trying to build a Wizard for populating data in to DataBase. I try the session.Wizard with out success plus I don't think this is what ti need. correct me if I am wrong. so ba
Solution 1:
found an answer from another post that is working by combining 2 people answer Switch case for form_class and template_name
@Denny Crane
classFoo(FormView):
defdispatch(self, request, *args, **kwargs):
self.var = request.session['sessionvar']['var']
if self.var == some_value:
form_class = form1
template_name = template1
elif self.var == another_value:
form_class = form2
template_name = template2
[...]
returnsuper(Foo, self).dispatch(request, *args, **kwargs)
@Serafeim
need to override get_form_class() as well
defget_form_class(self):
self.form_class = FORM[self.step]
returnself.form_class
Post a Comment for "Formview Cbv Change Modelform Per Request"