4π
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/3098817 -
Custom 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
2π
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.
- [Django]-Using DRF serializer to validate a list of dictionaries
- [Django]-Django: Passing object from template to views
2π
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:
url('/create_wizard/', factory_wizard, name='factory_wizard')
this is the factory:
class WizardClass(SessionWizardView):
...
def factory_wizard(request, *args, **kwargs):
parameter_to_know_which_step_number = # I let you implement this one ( I did it by the session data )
ret_form_list = [FirstFormClass, SecondFormClass]
for _ in range(parameter_to_know...):
form_list.append(SecondFormClass)
class ReturnClass(WizardClass):
form_list = ret_form_list
return ReturnClass.as_view()(request, *args, **kwargs)
- [Django]-Force reload on client's webpage Django
- [Django]-Django Registration Redux: how to change the unique identifier from username to email and use email as login
- [Django]-.Stay on SSL across redirects
- [Django]-Running a Django 1.4-based app on Google App Engine