[patch] django.contrib.formtools.wizard proposal
|Reported by:||Owned by:||Adrian Holovaty|
|Severity:||normal||Keywords:||newforms wizard sprintsept14|
|Cc:||Honza.Kral@…, nick.lane.au@…, larlet@…, jesse.lovelace@…, allandouglas@…, remco@…, matt.dorn@…, join.together@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have added some more flexibility and cleaned up the code a bit (and added comments ;) ).
- just subclass the wizard.Wizard class, override the
done()method and you are done - you can just point your urls.py to
MyWizard( [list, of, newform, classes] )and wait...
- data from previous steps are stored in hidden fields and passed back and forth (do not try and use this for uploading files in any, but the last step of the form ! ), NO data is stored on the server
- security hash is calculated once the form is validated ( thus you avoid validating each form every time and can detect manual tampering with the POST data)
If that's not enough you can (by overriding/extending some methods):
- create the list of forms dynamically (you still have to supply at least one form, so that the wizard has something to start with) - do this in
process_step()(just append to
self.form_list) -- see the last email for example
- use a custom template name for every step (
- override the rendering method for custom rendering (
- override the mechanism that handles the step counter - by default that is in
POST['wizard_step'], but you can put it in your URL, GET or even session if you wish (
- provide extra_context (from urls.py,
The only thing that is pretty much hardcoded is the use of POST throughout the wizard.
I am using the code (not the newest version, but I only made cosmeticall changes since) for some time now and everything works.
Once I get some feedback and a few people try it out, I will put together some documentation.
Change History (43)
comment:4 Changed 10 years ago by
|Component:||django.contrib.formtools → Unit test system|
|Severity:||normal → blocker|
|Version:||SVN → new-admin|
comment:5 Changed 10 years ago by
|Component:||Unit test system → django.contrib.formtools|
|Severity:||blocker → normal|
|Version:||new-admin → SVN|
Changed 9 years ago by
comment:18 Changed 9 years ago by
|Owner:||changed from mdorn to Honza Král|
|Status:||assigned → new|
comment:27 Changed 9 years ago by
|Owner:||changed from Honza Král to Adrian Holovaty|
|Status:||new → assigned|