summaryrefslogtreecommitdiff
path: root/tests/forms_tests/models.py
diff options
context:
space:
mode:
authorAlex Couper <alex.couper@glassesdirect.com>2013-07-20 21:49:33 +0000
committerTim Graham <timograham@gmail.com>2013-07-31 14:12:03 -0400
commit1123f4551158b7fc65d3bd88c375a4517dcd0720 (patch)
treecfded236931c3360205bf35351d81c75a78ef743 /tests/forms_tests/models.py
parenta1889397a9f0e6a35189de455098b4c70923e561 (diff)
Fixed #20649 -- Allowed blank field display to be defined in the initial list of choices.
Diffstat (limited to 'tests/forms_tests/models.py')
-rw-r--r--tests/forms_tests/models.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/forms_tests/models.py b/tests/forms_tests/models.py
index bec31d12d7..33898ffbb8 100644
--- a/tests/forms_tests/models.py
+++ b/tests/forms_tests/models.py
@@ -34,7 +34,30 @@ class Defaults(models.Model):
class ChoiceModel(models.Model):
"""For ModelChoiceField and ModelMultipleChoiceField tests."""
+ CHOICES = [
+ ('', 'No Preference'),
+ ('f', 'Foo'),
+ ('b', 'Bar'),
+ ]
+
+ INTEGER_CHOICES = [
+ (None, 'No Preference'),
+ (1, 'Foo'),
+ (2, 'Bar'),
+ ]
+
+ STRING_CHOICES_WITH_NONE = [
+ (None, 'No Preference'),
+ ('f', 'Foo'),
+ ('b', 'Bar'),
+ ]
+
name = models.CharField(max_length=10)
+ choice = models.CharField(max_length=2, blank=True, choices=CHOICES)
+ choice_string_w_none = models.CharField(
+ max_length=2, blank=True, null=True, choices=STRING_CHOICES_WITH_NONE)
+ choice_integer = models.IntegerField(choices=INTEGER_CHOICES, blank=True,
+ null=True)
@python_2_unicode_compatible