Thanks for the reply...
This is the kind of thing I am looking for. However I have tried this
approach and I could not get it working exactly right.
Along this line I have tried the following:
class MyForm(forms.Form):
def __init__(self, extra_param=None, *args, **kwargs):
self.extra_param = extra_param
super(MyForm, self).__init__(*args, **kwargs)
def clean(self):
# access your extra param with self.extra_param
class TestFormWizard(FormWizard):
extra_param = {}
def get_form(self, step, data=None):
"""Override the get form to add the extra param. This is ugly
IMO"""
return self.form_list[step](self.extra_param, data,
prefix=self.prefix_for_step(step), initial=self.initial.get(step,
None))
def parse_params(self, request, *args, **kwargs):
if request.method == 'POST':
form = self.get_form(current_step, request.POST)
if form.is_valid:
self.extra_param.update(form.cleaned_data)
Now this work in passing the data from the last form to the next...but
there are some cases I need data from 2 or 3 forms ago and this does
not seem to get passed (I feel this is from the web server recycling
processes)
On Oct 13, 6:29 pm, nabucosound <[email protected]> wrote:
> It is a common practice to pass extra parameters to the __init__
> function of the form and save them as properties of the object that
> can be later on accessed by any method like the clean method:
>
> class MyForm(forms.Form):
>
> def __init__(self, extra_param=None, *args, **kwargs):
> self.extra_param = extra_param
> super(MyForm, self).__init__(*args, **kwargs)
>
> def clean(self):
> # access your extra param with self.extra_param
>
> I don't know if is this what you are looking for...
>
> H.http://nomadblue.com/
>
> On Oct 13, 5:53 am, valhalla <[email protected]> wrote:
>
> > I am trying to figure out a pythonic way of passing data between the
> > forms of a formwizard.
> > I can do it with inital data but I need to access the data in the
> > clean method of the form.
>
> > The only ways I can get working are really messy and wont scale
> > easily.
>
> > Any suggestions out there?
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---