Django SessionWizardView not executing executed method

I cannot get the SessionWizardView to work. When I submit the last step, the wizard will go to the first step and will not execute the method I made.

views.py

class CvWizardView(CookieWizardView):
    form_list = [InfoPersonalForm, PresentacionForm]
    template_name = 'postulantes/cv_wizard.html'

    def done(self, form_list, **kwargs):
        return HttpResponseRedirect(reverse('wizard_done'))

      

urls.py

url(r'^wizard/$', CvWizardView.as_view() , name="wizard"),

      

Html

{% extends "base.html" %}
{% load i18n %}

{% block extra_head %}
{{ wizard.form.media }}
{% endblock %}

{% block content %}
<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p>
<form action="" 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>
{% endblock %}

      

Thank!

+3


source to share


2 answers


Try to send the user directly to the html page. In this case, change page_i_want_to_send_user.html

to the name of the page you want to send to the user after completing the form

class CvWizardView(CookieWizardView):
    form_list = [InfoPersonalForm, PresentacionForm]
    template_name = 'postulantes/cv_wizard.html'

     def done(self, form_list, **kwargs):  
            return render_to_response('page_i_want_to_send_user.html', {
                'form_data': [form.cleaned_data for form in form_list],            
            }) 

      



In this case, the page page_i_want_to_send_user.html

is stored inside the templates directory

0


source


You may have a field validation error. Try adding lines,

{{ wizard.form.non_field_errors }}
{{ wizard.form.errors }}

      

after the line,



{{ wizard.management_form }}

      

in your html template file. This should display any validation errors that prevent the executed method from executing.

0


source







All Articles