django wizard form problem in showing multiforms
NickName:Akaash Ask DateTime:2020-06-11T18:26:09

django wizard form problem in showing multiforms

My Views Page:

from django.shortcuts import render
from django.http import HttpResponse
from formtools.wizard.views import SessionWizardView
from .forms import ContactForm1,ContactForm2,ContactForm3


class ContactWizard(SessionWizardView):
    template_name = 'contact.html'
    form_list = [ContactForm1,ContactForm2]

    def done(self, form_list, **kwargs):
        form_data = process_form_data(form_list)

        return render_to_response('done.html', {'form_data': form_data})

    def process_form_data(form_list):
        form_data = [form.cleaned_data for form in form_list]

        return form_data

My form page:

from django import forms


class ContactForm1(forms.Form):enter code here
    subject = forms.CharField(max_length=100)


class ContactForm2(forms.Form):
    sender =  forms.EmailField()

class ContactForm3(forms.Form):
    message = forms.CharField(widget=forms.Textarea)

I am new to Django I am working with the wizard forms but this wizard form not showing the if statement of the wizard multiform. Please help me to solve the wizard form.

Html Page

{% load i18n %}

<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p>

{% for field in form %}
{{field.error}}
{% endfor %}
<form action="/contact/" method="post">
{% csrf_token %}
<table>
{{ wizard.management_form }}
{% if wizard.form.forms %}
    {{ wizard.form.management_form }}
    {% for form in wizard.form.forms %}
        {{ form }}
    {% endfor %}
{% else %}
    {{ wizard.form }}
{% endif %}
</table>
{% if wizard.steps.prev %}
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
{% endif %}
<input type="submit" value="{% trans "submit" %}"/>
</form>

Help to find out the problem in wizard multiform

Copyright Notice:Content Author:「Akaash」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62322228/django-wizard-form-problem-in-showing-multiforms

More about “django wizard form problem in showing multiforms” related questions

django wizard form problem in showing multiforms

My Views Page: from django.shortcuts import render from django.http import HttpResponse from formtools.wizard.views import SessionWizardView from .forms import ContactForm1,ContactForm2,ContactFor...

Show Detail

Django Form Wizard With Fieldsets

I'm using the Django Form Wizard (From 1.8 located in formtools) to split a form into multiple steps. This works fine and all. But I'm interested in making fieldsets in my form and splitting my form

Show Detail

Forcing steps with django form wizard

How would I force steps for the django form wizard? I have step 0 showing a Subscription page with different account types. I wanted to have the ability to send someone a link such as /join/basi...

Show Detail

Django form wizard - customized form layout for each step

At the moment I'm experimenting with django form wizard. The basic set-up works now and I'm able to call different templates for each step showing variable text. Now I want to take it a step furth...

Show Detail

Django form wizard dispatcher

I have a form that is two pages long. Although, the first page asks a basic question, and based on the answer it needs to redirect to one of three forms to be filled out, then submitted. I have cre...

Show Detail

Django Form Wizard to Edit Model

I have a Django form wizard working nicely for creating content of one of my models. I want to use the same Wizard for editing data of existing content but can't find a good example of how to do th...

Show Detail

Setting up Django Form Wizard

I'm attempting to set up a Django Form Wizard, but I'm having trouble getting it to work. I've followed the example, from the Django website, but can't get anything to work. When I go to the URL that

Show Detail

Django Form Wizard, how to reset/clear wizard?

I have created a Django Form Wizard which works fine. However, after finishing the wizard and starting it again, it loads the data generated during its previous use. Instead I would like it to clea...

Show Detail

Django form wizard cannot prevent form submission with Javascript

I am using a form wizard in django and I want to allow the form to submit only if a Javascript condition is true. For starters, let's say that I always want to block the form submission. So, I am ...

Show Detail

django form wizard with file upload multiple not working

I am currently digging into django form wizards and I am trying to upload multiple images. Unfortunately, the BaseStorage provided by django form wizard does not handle multiple files. It always as...

Show Detail