On Dec 17, 7:49 am, Rajesh Dhawan <[email protected]> wrote:
> On Dec 16, 2:31 am, 朱穆穆 <[email protected]> wrote:
>
> > Theextra_contextinFormWizardis a class attribute so the new
> > request may get the context of the previous request.
> > I can prepend below to __call__ method to solved it:
>
> > self.extra_context= self.extra_context.copy()
>
> > Is this really a bug?
>
> It's most probably a bug. See:http://code.djangoproject.com/ticket/8808
>
> Basically, if you hook theFormWizardinto your URL config as
> documented 
> athttp://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizar...,
> anything you set in self.extra_contextmay become available to another
> request.
>
> Your fix to copy theextra_contextdoesn't solve this problem.
>
> Quoting an excerpt from Jacob's response on that ticket: "I should
> note that the workaround is very simple: either don't store state on
> self, or instantiate the wizard in a view function. "
>
> -Rajesh D

I already instantiate the wizard in a view function when I send the
first mail.
Please notice that the extra_context is a class attribute.
Just instantiate the wizard in a view function did not solved the
problem, and my fix will solve it.

Add below will fix when instantiate the wizard in urlconf:

Change the last line in __call__ from:
  return self.render(form, request, current_step)
to:
  response = self.render(form, request, current_step)
  del self.extra_context  # here the extra_context is a copy in
instance, once delete, the next request will copy one from the class
extra_context
  return response


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to