mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #30931 -- Restored ability to override Model.get_FIELD_display().
Thanks Sergey Fedoseev for the implementation idea.
Regression in a68ea23101.
This commit is contained in:
committed by
Mariusz Felisiak
parent
8463390527
commit
2d38eb0ab9
@@ -168,6 +168,16 @@ class GetFieldDisplayTests(SimpleTestCase):
|
||||
self.assertIsInstance(val, str)
|
||||
self.assertEqual(val, 'translated')
|
||||
|
||||
def test_overriding_FIELD_display(self):
|
||||
class FooBar(models.Model):
|
||||
foo_bar = models.IntegerField(choices=[(1, 'foo'), (2, 'bar')])
|
||||
|
||||
def get_foo_bar_display(self):
|
||||
return 'something'
|
||||
|
||||
f = FooBar(foo_bar=1)
|
||||
self.assertEqual(f.get_foo_bar_display(), 'something')
|
||||
|
||||
def test_iterator_choices(self):
|
||||
"""
|
||||
get_choices() works with Iterators.
|
||||
|
||||
Reference in New Issue
Block a user