【发布时间】:2015-12-01 05:21:27
【问题描述】:
我目前有一个视图,我在函数末尾通过返回渲染传递参数,如下所示:
return render(request, 'a.html',
{'form': form,
'current_account': current_account,
'accounts': accounts},
)
由于设计的变化,我现在必须集成表单向导。如何通过表单向导将上述变量“current_account”和“accounts”传递给特定的 html,以便 html 正确呈现。如何将变量返回到 a.html?
这是我修改的表单向导功能:
class UserAccounts(SessionWizardView):
form_list = [FormA, FormB]
... more code ...
def get_form(self, step=None, data=None, files=None):
form = super(VerifyUserAccounts, self).get_form(step, data, files)
# determine the step if not given
if step is None:
step = self.steps.current
accounts = []
for item in number_of_accounts_wo_at:
accounts.append(item)
current_account = accounts[0]
accounts = accounts[1:]
return form
【问题讨论】:
标签: django django-templates django-views django-formwizard