diff gpp/polls/forms.py @ 1:dbd703f7d63a

Initial import of sg101 stuff from private repository.
author gremmie
date Mon, 06 Apr 2009 02:43:12 +0000
parents
children 1f139de929c4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/polls/forms.py	Mon Apr 06 02:43:12 2009 +0000
@@ -0,0 +1,16 @@
+"""Forms for the Polls application."""
+
+from django import forms
+
+from polls.models import Choice
+
+
+class VoteForm(forms.Form):
+   """Form for voting in a poll."""
+   choices = forms.ModelChoiceField(label='', empty_label=None,
+         queryset=Choice.objects.none(), widget=forms.RadioSelect)
+
+   def __init__(self, poll, *args, **kwargs):
+      super(VoteForm, self).__init__(*args, **kwargs)
+      self.fields['choices'].queryset = poll.choice_set.all()
+