I have a Django form wizard working nicely for creating content of one of my models. I want to use the same Wizard for editing data of existing content but can\'t find a good ex
I had to edit this a bit to get it working in Django 1.11 with django-formtools 2.1.
class ProjectWizard(SessionWizardView):
def get_form_initial(self, step):
if 'project_id' in self.kwargs:
return {}
return self.initial_dict.get(step, {})
def get_form_instance(self, step):
if not self.instance_dict:
if 'project_id' in self.kwargs:
project_id = self.kwargs['project_id']
return Project.objects.get(id=project_id)
return None
The get_form_instance
method now expects either an object or None to be returned.