Is possible that the steps of the wizard are dynamic? For example, the second step occur repeatedly n times?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
What do you want to do ?
If you want to create a wizard where step x is repeated n times then answer is yes, you can do that and it is not that hard.
You just need to create a wizard class factory that creates the class given specific parameters and you're done.
In case you mean, can I change the steps of a wizard on-the-fly. answer is still yes but then things will get a bit more complicated than that since you will have to change the internal state of the wizard after its initialization.
This is not fun at all, if you really need the second option I really suggest to think about it, try to find an alternative design and choose the dynamic wizard approach as last resort.
I struggled with this problem too. Tommaso Barbugli is right about creating a factory for the class. I'm currently working with Django 1.6.
in the url, include this:
this is the factory:
I had the same issue, and the form wizard (even in Django 1.4) just didn't work for me. It was so much customization that some things started to go wrong and debugging was awful.
I did write some code based on the existing clases. Please see my gists where I posted a solutions that worked great for me. If you have any comments or suggestions (including the name of the class), please post them.
Multi-page form manager, arranged as a (math) graph, with dynamic paths (next form depends on actual state and user input) and number of forms. Storage and validation are handled. Based in Django-1.4's
django.contrib.formtools.wizard.views.SessionWizardView
. https://gist.github.com/3098817Custom Django SessionStorage. Removed all the functionality that dealt with files. Based on Django-1.4's
django.contrib.formtools.wizard.storage.base.BaseStorage
anddjango.contrib.formtools.wizard.storage.session.SessionStorage
. https://gist.github.com/3080251