Form wizard

9 views
Skip to first unread message

vev...@yandex.ru

unread,
Jun 19, 2011, 7:41:25 AM6/19/11
to Django users
Please give me a reference to a full example of Form wizard.
To learn it I try to solve such an application (details are omitted):
urls.py:
urlpatterns = patterns('',
(r'^hotel_wizard/', 'my.app.views.hotel_info'),
models.py:
class Country(models.Model):
name = models.CharField(max_length=50)
objects = models.Manager()
class Region(models.Model):
name = models.CharField(max_length=50)
country = models.ForeignKey(Country)
objects = models.Manager()
class Hotel(models.Model):
name = models.CharField(max_length=255)
region = models.ManyToManyField(Region)
price = models.IntegerField()
objects = models.Manager()
forms.py:
class HotelForm1(forms.Form):
country = forms.ModelChoiceField(queryset=Country.objects.all())
class HotelForm2(forms.Form):
region = forms.ModelChoiceField(queryset=Region.objects.all()) ???
price = forms.DecimalField(max_digits=7)
class HotelWizard(FormWizard):
def done(self, request, form_list):
return HttpResponseRedirect('/page-to-redirect-to-when-done/')
I stopped at this step. How can I pass country selected to HotelForm2
and use it in queryset, and so on.
Maybe the best way for me is to look at an example. I didn't find it
in djangoproject.com and 3 books on Django I have.
Thank you!

Kevin Renskers

unread,
Jun 22, 2011, 4:31:01 AM6/22/11
to django...@googlegroups.com
The documentation on https://docs.djangoproject.com/en/1.3/ref/contrib/formtools/form-wizard/ is pretty clear. The part where you're going in the wrong direction is the url config. Compare with https://docs.djangoproject.com/en/1.3/ref/contrib/formtools/form-wizard/#hooking-the-wizard-into-a-urlconf.
Reply all
Reply to author
Forward
0 new messages