Opened 5 years ago

Closed 4 years ago

#15050 closed Bug (fixed)

FormWizard URLConf documentation misleading

Reported by: root+django@… 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:

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 Changed 5 years ago by russellm

  • Component changed from Documentation to django.contrib.formtools
  • Keywords wizard added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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).

comment:2 Changed 4 years ago by anonymous

  • Severity set to Normal
  • Type set to Bug

comment:3 Changed 4 years ago by jezdez

  • Easy pickings unset
  • Resolution set to fixed
  • Status changed from new to closed

Superseded by #9200.

Note: See TracTickets for help on using tickets.
Back to Top