2013-03-13 35 views
0

我想使用窗體嚮導來使用不同的模板名稱,但我得到一個錯誤,我不明白爲什麼它看起來像它只是直截了當。窗體嚮導:錯誤未定義的變量

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/') 

回答

1
from solution import forms * 

FORMS = [ 
    ("customer", customerForm), 
    ("building", buildingForm) 
] 
+0

感謝ü@princess ......知道了:) – noobes 2013-03-13 20:03:13