我正在尝试使用表单向导来使用不同的模板名称,但是我得到一个错误,我不明白为什么会让它看起来像是直接的。
using different template for each form
views.py
from django.http import HttpResponseRedirect
from django.contrib.formtools.wizard.views import SessionWizardView
FORMS = [("customer", solution.forms.customerForm), //got error undefined variables:solution
("building", solution.forms.buildingForm)]
TEMPLATES = {"customer": "customer.html",
"building": "building.html",
}
class customerWizard(SessionWizardView):
def get_template_names(self):
return [TEMPLATES[self.steps.current]]
def done(self, form_list, **kwargs):
do_something_with_the_form_data(form_list) //get error undefined variables
return HttpResponseRedirect('/page-to-redirect-to-when-done/')
答案 0 :(得分:1)
from solution import forms *
FORMS = [
("customer", customerForm),
("building", buildingForm)
]