mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #31124 -- Fixed setting of get_FOO_display() when overriding inherited choices.
Regression in 2d38eb0ab9
This commit is contained in:
committed by
Carlton Gibson
parent
d202846ced
commit
29c126bb34
@@ -764,7 +764,11 @@ class Field(RegisterLookupMixin):
|
||||
if not getattr(cls, self.attname, None):
|
||||
setattr(cls, self.attname, self.descriptor_class(self))
|
||||
if self.choices is not None:
|
||||
if not hasattr(cls, 'get_%s_display' % self.name):
|
||||
# Don't override a get_FOO_display() method defined explicitly on
|
||||
# this class, but don't check methods derived from inheritance, to
|
||||
# allow overriding inherited choices. For more complex inheritance
|
||||
# structures users should override contribute_to_class().
|
||||
if 'get_%s_display' % self.name not in cls.__dict__:
|
||||
setattr(
|
||||
cls,
|
||||
'get_%s_display' % self.name,
|
||||
|
||||
Reference in New Issue
Block a user