I am trying to write a quiz application.i have the follwing model.
class Question(db.Model):
question=db.StringProperty(required=True)
answer_1=db.StringProperty(required=True)
answer_2=db.StringProperty(required=True)
answer_3=db.StringProperty(required=True)
answer_4=db.StringProperty(required=True)
correct_answer=db.StringProperty(choices=['1','2','3','4'])
and the following form
class QuestionForm(ModelForm):
class Meta:
model=Question
which served me well for creating forms for submitting new questions.
Now i want the stored Questions in the database to be presented in form for a Quiz to the user.The above form would generate the form as having
<input type="text">
while i want them to have radio boxes how do i achive the same? do i need a seperate form class ?
You could also store the possibie answers in another model, admin them through an inline admin (whcih would give you more flexibility, because the number of answers doesnt always have to be the same then), and the use a foreign key field for the correct answer (which will render as dropdown or radio boxes if you wish)!