[Answered ]-Django FormWizard Dynamically Alter form_list

2👍

How do you use FormWizard? If you’re putting it in urls.py like docs says then it could be cached, i had that issue couple of times. Just put it in a view like:

def my_view(request):
    return FormWizard(request)

UPDATE: Example from real

def registration_wizard(request, template_name=None):
    rw = RegistrationWizard([RegistrationForm, 0])
    #hack formwizard to replace default template
    if template_name:
        rw.get_template = lambda x: template_name

    return rw(request)

here RegistrationWizard is a FormWizard subclass with dynamic form_list, [RegistrationForm, 0] is needed because if there’s only one form at creation time, wizard won’t get to form_list function. Template thing is pretty self-explanatory

Leave a comment