Wednesday, February 25, 2015

Re: Form Wizard: store the session values

Solved with a very easy approach.

I override the WizardView get method and I use a session variable to understand if the user want to restore the edit or create a new form

   def get(self, request, *args, **kwargs):
        """
        This method override the WizardView handling the restore of the session
        if the value request.session['restore-wizard'] is True
        """
        try:
            if request.session['restore-wizard']:
                return self.render(self.get_form())
        except KeyError:
            # just call the default super get
            return super(ServiceCreationWizard, self).get(request, *args, **kwargs


--
Karim N. Gorjux

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACeuRGX8%3DCU9uwi_n3bX1hh3yZx8JSPSTV8OuJwguDW%3D-7irqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment