mirror of https://github.com/django/django.git
Fixed #29854 -- Made _all_related_fields() return deterministically ordered fields.
Thanks to Rick Yang and Baptiste Mispelon for the investigation.
This commit is contained in:
parent
c5fd5e3cc3
commit
3b898ea61e
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import operator
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.db.backends.ddl_references import (
|
from django.db.backends.ddl_references import (
|
||||||
|
@ -35,11 +36,15 @@ def _is_relevant_relation(relation, altered_field):
|
||||||
|
|
||||||
|
|
||||||
def _all_related_fields(model):
|
def _all_related_fields(model):
|
||||||
return model._meta._get_fields(
|
# Related fields must be returned in a deterministic order.
|
||||||
|
return sorted(
|
||||||
|
model._meta._get_fields(
|
||||||
forward=False,
|
forward=False,
|
||||||
reverse=True,
|
reverse=True,
|
||||||
include_hidden=True,
|
include_hidden=True,
|
||||||
include_parents=False,
|
include_parents=False,
|
||||||
|
),
|
||||||
|
key=operator.attrgetter("name"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue