Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在每个步骤中为我的 django 表单向导传递不同的模板。
我想检查表单向导的 get_template() 函数中的每个步骤。如果我尝试:
def get_template(self,step): if step == 1: return 'test_1.html' return 'test_2.html'
它返回 test_2.html。我正在从我的模板中检查我的步骤并根据步骤编号生成一个表单,但这似乎不是一个好方法。任何的想法 ?
根据高级FormWizard方法的文档,step是一个从零开始的计数器。
FormWizard
step
所以在第一种形式上,step是0,不是1。那会抓到你吗?您可能希望将代码更改为:
0
1
if step == 0: