Here’s the basic workflow for how a user would use a wizard:
The user visits the first page of the wizard, fills in the form and submits it.
The server validates the data. If it’s invalid, the form is displayed again, with error messages. If it’s valid, the server saves the current state of the wizard in the backend and redirects to the next step.
Step 1 and 2 repeat, for every subsequent form in the wizard.
Once the user has submitted all the forms and all the data has been validated, the wizard processes the data – saving it to the database, sending an email, or whatever the application needs to do.
您可以考虑的一种方法是将您的模型拆分为语义片段,每个片段都是一个单独的模型,具有更多可消化的字段。你知道吗
然后使用一对一关系(由OneToOneField实现)将这些“切片模型”映射回主对象。你知道吗
在您的向导中,您可以在事务开始时启动事务,并且只有在一切正常运行时才提交。你知道吗
Django有一个Form wizard可以存储跨多个页面累积的信息,验证每一步。你知道吗
相关问题 更多 >
编程相关推荐