From 390606e3d549ce5a911747e957e4c9d9acbbc995 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 13 Jan 2021 09:51:13 +0100 Subject: [PATCH] wizard finally working (proof of conecpt) --- evapp/views.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/evapp/views.py b/evapp/views.py index 5a27ea8..be6cd46 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -45,18 +45,29 @@ def send_mail_to_department(department, data): class EvaFormView(CookieWizardView): - model = Employee + # model = Employee template_name = 'evapp/employee_form.html' form_list = [PersonalForm, WorkingForm] - + instance = None # form_class = EmployeeForm def get_success_url(self): return reverse('success') + #this makes shure, that we use the same model instance for all steps + def get_form_instance(self,step): + if self.instance == None: + self.instance = Employee() + return self.instance + def done(self, form_list, **kwargs): - # self.model.save() + # form = form_list[0] #.save() + print ('INSTANCE_DICT') + print(self.instance_dict) + for form in form_list: + form.save() form_data = [form.cleaned_data for form in form_list] + print(form_data) for dep in MAILS: send_mail_to_department(dep, form_data) return render(self.request, 'evapp/dataloop.txt', {