Open motatoes opened 5 years ago
Hi Motatoes, did you get assistance with this problem? I am struggling with the same issue.
@BongzMD I did not get an answer regarding formtools and I don't remember if I found out what was wrong so I created my own wizard view
I made all the fields in my table nullable. I have a create report view which included:
class CreateReportView(LoginRequiredMixin,
ReportPermissionMixin,
RedirectView):
def get_redirect_url(self, *args, **kwargs):
# creating a draft report
self.report_add_permission(self.request)
report = Report.objects.create(user=self.request.user)
return reverse('reporting:report_update', kwargs={"pk": report.id})
I also copied bits of the SesssionWizard for my UpdateReportView
but instead of using a session I save the form records directly in the table at every step (provided the form is valid)
Okay thanks
On Sun, 3 May 2020, 12:52 Mohamed, notifications@github.com wrote:
@BongzMD https://github.com/BongzMD I did not get an answer regarding formtools and I don't remember if I found out what was wrong so I created my own wizard view
I made all the fields in my table nullable. I have a create report view which included:
class CreateReportView(LoginRequiredMixin, ReportPermissionMixin, RedirectView): def get_redirect_url(self, *args, **kwargs):
creating a draft report
self.report_add_permission(self.request) report = Report.objects.create(user=self.request.user) return reverse('reporting:report_update', kwargs={"pk": report.id})
I also copied bits of the SesssionWizard for my UpdateReportView but instead of using a session I save the form records directly in the table at every step (provided the form is valid)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jazzband/django-formtools/issues/147#issuecomment-623090882, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOLJUSH7HJQXKPEEOO7X7H3RPVEHBANCNFSM4IMMV3JQ .
From your template, the "next" button only takes you to the next page but doesn't actually 'save' the data. you can fix that by using an input field instead on the next button as seen below.
<input type="submit" value="{% trans "Next" %}"/>
Isn't there a way to save data in the session and reuse it in the steps? directly saving to DB seems a little wrong to me tbh...
Btw, the behaviour is the same for me for SessionWizardView
or CookieWizardView
I also have this issue
From your template, the "next" button only takes you to the next page but doesn't actually 'save' the data. you can fix that by using an input field instead on the next button as seen below.
<input type="submit" value="{% trans "Next" %}"/>
When trying @stephappiah's I get a SuspiciousOperation error saying "ManagementForm data is missing or has been tampered."
EDIT: Apparently I misspelled wizard.management_form
I asked this question on stackoverflow. My question is about saving information between fields.
I am trying to create a multi-step form wizard using django-formtools. I have a main model called
Report
and several ModelForms as follows:in my views, I have created the following view:
And my relevant template looks as follows:
My urls.py look as follows:
My problem is that the form steps are not being saved when I click on
next
, and thenprevious
(the form is valid). Bellow is an exampleFirst form loaded:
After clicking on 'next':
Now when i click on 'previous', everything is gone:
I wonder what I have missed?