diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2020-01-07 11:52:09 +0100 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2020-01-15 15:36:28 +0100 |
| commit | 57468eaff3de78918be5fb15a7984e49d7d3d103 (patch) | |
| tree | ee54fe217fa01c831a7cadb90ae12780db59311c /tests | |
| parent | 8712027b226f1400ea31f9c0500fbfe359dd9d07 (diff) | |
[3.0.x] Fixed #31124 -- Fixed setting of get_FOO_display() when overriding inherited choices.
Regression in 2d38eb0ab9f78d68c083a5b78b1eca39027b279a
Backport of 29c126bb349526b5f1cd78facbe9f25906f18563 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/model_fields/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index e399f68134..ac996e87f3 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -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. |
