How to call View from another view in django?

192 views Asked by At

I am creating a wizard using django-formtools.

I have created a view for the wizard :

class UserQueryWizard(SessionWizardView):

    template_name = "wizards/index.html"
    form_list = [forms.ShippingForm,
                 forms.ExporterdetailsForm, forms.ImporterdetailsForm, ]

    def done(self, form_list, **kwargs):
        print([form.cleaned_data for form in form_list])
        return render(self.request, 'wizards/index.html', {
            'form_data': [form.cleaned_data for form in form_list],
        })

    def get(self, request, *args, **kwargs):    
        try:
            return self.render(self.get_form())
        except KeyError:
            return super().get(request, *args, **kwargs)

I have another view that can be called with the post request

 path('query/', views.UserQueryView.as_view(), name='user_query'),

I Want to call the 'query/' URL with Post request in my done function

def done(self, form_list, **kwargs):
    print([form.cleaned_data for form in form_list])
    return <--- here with POST data([form.cleaned_data for form in form_list]) 
0

There are 0 answers