In generic UpdateView
, if you need to dynamically change the form depending on the passed object you can use this function (as in this answer):
def get_form_class(self):
if self.object.pk == 1:
return MyForm
else:
return OtherForm
Is there a similar function if I want to change the model
? where model is:
class SomeUpdateView(generic.UpdateView):
login_required = True
template_name = '...'
model = SomeModel ## I need it to be dynamic
form_class = SomeForm
success_url = reverse_lazy('some_url')