0

我想在每个步骤中为我的 django 表单向导传递不同的模板。

我想检查表单向导的 get_template() 函数中的每个步骤。如果我尝试:

def get_template(self,step):
    if step == 1:
        return 'test_1.html'
    return 'test_2.html'

它返回 test_2.html。我正在从我的模板中检查我的步骤并根据步骤编号生成一个表单,但这似乎不是一个好方法。任何的想法 ?

4

1 回答 1

0

根据高级FormWizard方法的文档,step是一个从零开始的计数器。

所以在第一种形式上,step0,不是1。那会抓到你吗?您可能希望将代码更改为:

if step == 0:

于 2011-10-26T20:54:10.167 回答