mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
[3.0.x] Fixed #31124 -- Fixed setting of get_FOO_display() when overriding inherited choices.
Regression in2d38eb0ab9
Backport of29c126bb34
from master
This commit is contained in:
parent
8712027b22
commit
57468eaff3
4 changed files with 31 additions and 1 deletions
|
@ -829,6 +829,15 @@ Note that in the case of identical date values, these methods will use the
|
|||
primary key as a tie-breaker. This guarantees that no records are skipped or
|
||||
duplicated. That also means you cannot use those methods on unsaved objects.
|
||||
|
||||
.. admonition:: Overriding extra instance methods
|
||||
|
||||
In most cases overriding or inheriting ``get_FOO_display()``,
|
||||
``get_next_by_FOO()``, and ``get_previous_by_FOO()` should work as
|
||||
expected. Since they are added by the metaclass however, it is not
|
||||
practical to account for all possible inheritance structures. In more
|
||||
complex cases you should override ``Field.contribute_to_class()`` to set
|
||||
the methods you need.
|
||||
|
||||
Other attributes
|
||||
================
|
||||
|
||||
|
|
|
@ -31,3 +31,7 @@ Bugfixes
|
|||
:class:`~django.contrib.postgres.aggregates.ArrayAgg` and
|
||||
:class:`~django.contrib.postgres.aggregates.StringAgg` with ``filter``
|
||||
argument when used in a ``Subquery`` (:ticket:`31097`).
|
||||
|
||||
* Fixed a regression in Django 2.2.7 that caused
|
||||
:meth:`~django.db.models.Model.get_FOO_display` to work incorrectly when
|
||||
overriding inherited choices (:ticket:`31124`).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue