1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +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:
Carlton Gibson
2019-10-31 11:34:56 +01:00
committed by Mariusz Felisiak
parent 8463390527
commit 2d38eb0ab9
3 changed files with 19 additions and 2 deletions

View File

@@ -763,8 +763,12 @@ class Field(RegisterLookupMixin):
if not getattr(cls, self.attname, None):
setattr(cls, self.attname, self.descriptor_class(self))
if self.choices is not None:
setattr(cls, 'get_%s_display' % self.name,
partialmethod(cls._get_FIELD_display, field=self))
if not hasattr(cls, 'get_%s_display' % self.name):
setattr(
cls,
'get_%s_display' % self.name,
partialmethod(cls._get_FIELD_display, field=self),
)
def get_filter_kwargs_for_object(self, obj):
"""