D
D
Dmitry Koldyaev2015-01-30 22:06:17
Django
Dmitry Koldyaev, 2015-01-30 22:06:17

How to display the first step django.formtool.wizard on all pages of the site?

The site has a booking form. Broken down into three stages.
I have a wizard defined

class OrderWizard(SessionWizardView):
    template_name = 'order/form.html'
    form_list = [OrderForm1, OrderForm2, OrderForm3]

When using its as_view() method, all is well. All three steps go well.
Now I want to make the first step on all pages of the site. So that the user can fill out the first part from any page, and only then go directly to the second page of the form.
To do this, I pass the wizard to the context processor
def left_order_form(request):

    if request.path != reverse('excursion_order') :
        wizard = OrderWizard()
    else :
        wizard = None

    return {
        'left_col_wizard':  wizard
    }

also I try to receive in a template
{{ left_col_wizard.form }}
But this variable is empty.
How can I implement what I want?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Koldyaev, 2015-01-30
@dkoldyaev

Instead of passing a class, it was necessary to generate a TemplateResponse and select the wizard object from it. Thanks to Rostislav Grigoriev for the solution!

def left_order_form(request):

    if request.path != reverse('excursion_order') :
        wizard = OrderWizard.as_view()(request).context_data['wizard']
    else :
        wizard = None

    return {
        'left_col_wizard':  wizard
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question