我想做一個簡單的測驗應用程序。我正在嘗試使用Form Wizard,但在文檔中沒有看到爲表單字段設置選項的任何內容。我也想多次使用相同的表單域。在窗體嚮導中設置字段的選擇?
models.py
class Choice(models.Model):
choice = models.CharField(max_length=64)
def __unicode__(self):
return self.choice
#create a multiple choice quiz to start
class Question(models.Model):
question = models.CharField(max_length=64)
answer = models.CharField(max_length=64)
choices = models.ManyToManyField(Choice)
module = models.CharField(max_length=64)
def __unicode__(self):
return self.question
class Quiz(models.Model):
name = models.CharField(max_length=64)
questions = models.ManyToManyField(Question)
def __unicode__(self):
return self.name
views.py
class QuizWizard(SessionWizardView):
def done(self, form_list, **kwargs):
return render_to_response('done.html', {
'form_data':[form.cleaned_data for form in form_list],
})
urls.py
url(r'^answer/(?P<question_id>\d+)', 'quiz.views.answer_question', name='answer_question'),
我知道如何設置字段的選擇,但是當我使用Form Wizard並傳入表單時,我不知道如何設置字段的選項。我無法在表單中設置選項,因爲它會針對每個問題進行更改,而且我對每個問題都使用相同的表單。.... – Siecje 2013-03-26 20:12:49