1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #31124 -- Fixed setting of get_FOO_display() when overriding inherited choices.

Regression in 2d38eb0ab9
This commit is contained in:
Carlton Gibson
2020-01-07 11:52:09 +01:00
committed by Carlton Gibson
parent d202846ced
commit 29c126bb34
4 changed files with 31 additions and 1 deletions

View File

@@ -178,6 +178,19 @@ class GetFieldDisplayTests(SimpleTestCase):
f = FooBar(foo_bar=1)
self.assertEqual(f.get_foo_bar_display(), 'something')
def test_overriding_inherited_FIELD_display(self):
class Base(models.Model):
foo = models.CharField(max_length=254, choices=[('A', 'Base A')])
class Meta:
abstract = True
class Child(Base):
foo = models.CharField(max_length=254, choices=[('A', 'Child A'), ('B', 'Child B')])
self.assertEqual(Child(foo='A').get_foo_display(), 'Child A')
self.assertEqual(Child(foo='B').get_foo_display(), 'Child B')
def test_iterator_choices(self):
"""
get_choices() works with Iterators.