gpt4 book ai didi

python - Django SessionWizardView 不执行完成方法

转载 作者:行者123 更新时间:2023-11-28 19:20:39 30 4
gpt4 key购买 nike

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

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 %}

谢谢!

最佳答案

尝试将用户直接发送到 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],
})

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

关于python - Django SessionWizardView 不执行完成方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26121428/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com