Skip to content

Instantly share code, notes, and snippets.

@ashchristopher
Created May 13, 2015 19:25
Show Gist options
  • Save ashchristopher/2efcd1afc539975100a6 to your computer and use it in GitHub Desktop.
Save ashchristopher/2efcd1afc539975100a6 to your computer and use it in GitHub Desktop.
Django's ChoiceField error.
from django import forms
CHOICES = (
('1', 1),
('2', 2),
('3', 3),
('4', 4),
('5', 5),
)
class BugForm(forms.Form):
days_since_last_bug = forms.TypedChoiceField(choices=CHOICES, coerce=long)
data = {'days_since_last_bug': '0', }
form = BugForm(data)
assert form.is_valid() == False, "0 should not be a valid choices for this field"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment