Fixed #30076 -- Added Model.get_FOO_display() even if field's choices are empty.

This commit is contained in:
Joshua Cannon 2019-01-04 14:03:53 -06:00 committed by Tim Graham
parent bae66e759f
commit 16a5a2a2c8
3 changed files with 80 additions and 9 deletions

View file

@ -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)