问题描述
可以在django SessionWizardView中包含一个非格式的网页吗?
Can a non-form web page be included in a django SessionWizardView?
例如,我想要用户FillOut Form1,Form2,然后查看一个网页(在同一个会话中)(点击下一步),然后单击Form3?所有这一切,同时保持相同的会话。
For example, I want the user to FillOut Form1, Form2, Then View a web page (in same session) (click next), and then Form3? All this while maintaining the same session.
如果是这样,最好的结果如何?任何示例或片段?
If so, how is this best accomplished? Any examples or snippets?
推荐答案
这是一个相当容易的黑客。创建一个普通的旧表单,其中有一个字段是用户隐藏的,没有内容,不需要。
There's a fairly easy hack for this. Create a plain old form that has one field that is hidden from the user, has no content, and isn't required.
我这样做:
class BlankForm(forms.Form):
nothing = forms.CharField(required=False, widget=HiddenInput)
将其包含在SessionWizardView调用中,就像其他页面一样:
Include it in your SessionWizardView call just like the other pages:
SessionWizardView.as_view([Form1, Form2, BlankForm, Form3])
在模板页面中,您可以使用这样的逻辑显示信息:
In the template page you can use some logic like this to display info:
{% if wizard.steps.current == '2' %}
Whatever you want to show on the BlankForm
{% endif %}
这篇关于在Django SessionWizardView中包含非格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!