diff options
| author | Joshua Cannon <joshua.cannon@ni.com> | 2019-01-04 14:03:53 -0600 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-01-30 13:44:10 -0500 |
| commit | 16a5a2a2c8d8dbf9cc3e033dd84b986bcaadb963 (patch) | |
| tree | a760f553b50f30f8d29b601cd81292997de83f5a /tests/model_fields/models.py | |
| parent | bae66e759faee8513da4b11d3fd16b044b415bdb (diff) | |
Fixed #30076 -- Added Model.get_FOO_display() even if field's choices are empty.
Diffstat (limited to 'tests/model_fields/models.py')
| -rw-r--r-- | tests/model_fields/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py index 13d4843632..02fea36b31 100644 --- a/tests/model_fields/models.py +++ b/tests/model_fields/models.py @@ -50,6 +50,14 @@ class Whiz(models.Model): c = models.IntegerField(choices=CHOICES, null=True) +class WhizDelayed(models.Model): + c = models.IntegerField(choices=(), null=True) + + +# Contrived way of adding choices later. +WhizDelayed._meta.get_field('c').choices = Whiz.CHOICES + + class WhizIter(models.Model): c = models.IntegerField(choices=iter(Whiz.CHOICES), null=True) @@ -58,6 +66,14 @@ class WhizIterEmpty(models.Model): c = models.CharField(choices=iter(()), blank=True, max_length=1) +class Choiceful(models.Model): + no_choices = models.IntegerField(null=True) + empty_choices = models.IntegerField(choices=(), null=True) + with_choices = models.IntegerField(choices=[(1, 'A')], null=True) + empty_choices_bool = models.BooleanField(choices=()) + empty_choices_text = models.TextField(choices=()) + + class BigD(models.Model): d = models.DecimalField(max_digits=32, decimal_places=30) |
