gpt4 book ai didi

django - 如何制作 "workflow"表格

转载 作者:行者123 更新时间:2023-12-01 13:07:40 25 4
gpt4 key购买 nike

对于我的项目,我需要许多“工作流”表单。我自己解释:

用户在第一个字段中选择一个值,验证表单并根据第一个字段值出现新字段。然后,根据其他字段,可以出现新字段...

如何以通用方式实现它?

最佳答案

我认为您正在寻找的解决方案是 django form wizard

基本上,您为不同的页面定义单独的表单,并根据先前屏幕中的输入自定义下一个表单,最后,您将所有表单的数据放在一起。

具体看process step表单向导中的高级选项。

FormWizard.process_step()
"""
Hook for modifying the wizard's internal state, given a fully validated Form object. The Form is guaranteed to have clean, valid data.
This method should not modify any of that data. Rather, it might want to set self.extra_context or dynamically alter self.form_list, based on previously submitted forms.
Note that this method is called every time a page is rendered for all submitted steps.
The function signature:
"""

def process_step(self, request, form, step):
# ...

如果您只需要根据同一表单中的其他下拉菜单修改下拉菜单值,您应该查看已实现的 dajaxproject

关于django - 如何制作 "workflow"表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1875091/

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