You have a list of fields on which you need to visualize the quiz, as I understand it. So, the list is as follows:
questions = (
('Place your 1 answers %s and %s.', ('field_1_1', 'field_2_2')),
('Place your 2 answers %s and %s.', ('field_2_1', 'field_2_2')),
)
You can create a form for each field, for example:
class QuizzForm(forms.Form):
def __init__(self, *args, **kwargs):
super(QuizzForm, self).__init__(*args, **kwargs)
for question in questions:
for field in question[1]:
self.fields[field] = forms.ChoiceField()
And access the fields after a message similar to this:
if form.is_valid():
for question in questions:
for field in question[1]:
answer = form.cleanded_data.get(field)
source
share