Thanks Rajesh

But...it doesn't work
It complains about form0 doesn't have cleaned_data. I guess

form0 = super(MyFormWizard, self).get_form(0, data=data)

only gives you a form with no data?!



On Aug 20, 11:06 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > Depending onstep1's selection, I want tosetthequerysetof one of
> > the fields (a ModelChoiceField)
>
> > e.g.
> > class StepOneForm(forms.Form):
> >    channelType =
> > forms.ModelChoiceField(queryset=ChannelType.objects.all())
> > class StepTwoForm(forms.Form):
> >    channel = forms.ModelChoiceField()
>
> > class MyFormWizard(FormWizard):
> >    def process_step(self, request,form,step):
> >         ifstep==0:
> >             self.get_form(1).channel.queryset=
> >form.cleaned_data['channelType'].channel_set.all()
>
> The process_step method is called only after theformis already
> validated. So, as you found out, that's not going to work. Also, you
> are trying tosetthequerysetonform#1 whenstepis 0. That's not
> going to persist.
>
> > But it doesn't seems working... how can a dynamic choice can be
> > achieved depending on selection of previousstep?!
>
> Try overriding the get_form method instead of process_step. Also, you
> will need to populateform#1'squerysetwhen you are instep1. So,
> the code would be something like this:
>
> def get_form(self,step, data=None):
>    form= super(MyFormWizard, self).get_form(step, data=data)
>     ifstep== 1:
>         # Getstep#0'sformandsetform#1'squerysetbased on it
>                 form0 = super(MyFormWizard, self).get_form(0, data=data)
>                form.fields['channel'].queryset=
> form0.cleaned_data['channelType'].channel_set.all()
>     returnform
>
> -Rajesh D
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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