1 # This file is part of KOED-Quiz, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django import forms
5 from django.forms.widgets import RadioSelect
6 from django.utils.translation import ugettext_lazy as _
7 from quiz.models import Answer
9 class QuestionForm(forms.Form):
10 answer = forms.ModelChoiceField(widget=RadioSelect,
11 queryset=Answer.objects.all(), empty_label=None,
12 error_messages={'required': _('Please select an option')})
14 def __init__(self, instance, *args, **kwargs):
15 r = super(QuestionForm, self).__init__(*args, **kwargs)
16 self.fields['answer'].queryset = instance.answer_set.all()