Opened 14 years ago
Closed 13 years ago
#15050 closed Bug (fixed)
FormWizard URLConf documentation misleading
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.formtools | Version: | 1.2 |
Severity: | Normal | Keywords: | wizard |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The documentation suggests the following way to plug a FormWizard into the URLConf:
from django.conf.urls.defaults import * from testapp.forms import ContactForm1, ContactForm2, ContactWizard urlpatterns = patterns('', (r'^contact/$', ContactWizard([ContactForm1, ContactForm2])), )
Unfortunately, this causes a single instance of the wizard to serve the whole application. Basically, all instance attributes are shared between all visitors (e.g. self.step, so the wizard is effectively unusable).
To make the wizard handle every request in a dedicated instance, a wrapper function could be used, a'la:
def contact_wizard(request, *args, **kwargs): wizard = ContactWizard([ContactForm1, ContactForm2]) return wizard(request, *args, **kwargs) urlpatterns = patterns('', (r'^contact/$', contact_wizard), )
Change History (3)
comment:1 by , 14 years ago
Component: | Documentation → django.contrib.formtools |
---|---|
Keywords: | wizard added |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:3 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Superseded by #9200.
Note:
See TracTickets
for help on using tickets.
This isn't just a documentation issue -- it's pointing at a pretty glaring hole in the formwizard as currently implemented.
Essentially, FormWizard needs to be updated to use Django's own class-based view structure (which took a long time to finalize specifically because of the issue you describe here). The good news is that there is at least one effort in the works to do just this -- Stephan Jäkel, has been working on django-formwizard to address this, and a couple of other problems with the FormWizard framework (#7439, #9200, #11112).