Django SessionWizardView不执行done方法

Fra*_*sco 5 python forms django wizard

我无法让我的 SessionWizardView 工作。当我提交最后一步时,向导跳回第一步,不执行done方法。

视图.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'))
Run Code Online (Sandbox Code Playgroud)

urls.py

url(r'^wizard/$', CvWizardView.as_view() , name="wizard"),
Run Code Online (Sandbox Code Playgroud)

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 %}
Run Code Online (Sandbox Code Playgroud)

谢谢!

Dee*_*end 0

尝试将用户直接发送到 html 页面。在这种情况下,更改page_i_want_to_send_user.html为您希望用户在完成表单后发送到的页面的名称

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],            
            }) 
Run Code Online (Sandbox Code Playgroud)

在这种情况下,page_i_want_to_send_user.html页面存储在 templates 目录中