Hello list, Today I started using FormWizard and could not find a clean way to populate a choices field based on previously submitted forms, I ended up overriding the render method like this(The only changed line is the one highlited): {{{ class CountryForm(forms.Form): country = forms.ModelChoiceField(queryset=Country.objects.all())
class StaterForm(forms.Form): state = forms.ChoiceField() class LocationFormWizard(forms.Form): def process_step(self, request, form, step): if step == 0 and form.is_valid(): self.state_choices= states_from_country(form.data['0-country']) def prepare_form(self, request, form, step): if step == 1: form.fields['state'].choices = self.state_choices return form def render(self, form, request, step, context=None): "Renders the given Form object, returning an HttpResponse." old_data = request.POST prev_fields = [] form = self.prepare_form(request,form, step) if old_data: hidden = forms.HiddenInput() # Collect all data from previous steps and render it as HTML hidden fields. for i in range(step): old_form = self.get_form(i, old_data) hash_name = 'hash_%s' % i prev_fields.extend([bf.as_hidden() for bf in old_form]) prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form)))) return self.render_template(request, form, ''.join(prev_fields), step, context) }}} Is there a hook missing to do what I needed or am I missing something? Ariel --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---