1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

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:
Collin Anderson
2022-04-26 14:15:26 -04:00
committed by Mariusz Felisiak
parent c5fd5e3cc3
commit 3b898ea61e

View File

@@ -1,4 +1,5 @@
import logging
import operator
from datetime import datetime
from django.db.backends.ddl_references import (
@@ -35,11 +36,15 @@ def _is_relevant_relation(relation, altered_field):
def _all_related_fields(model):
return model._meta._get_fields(
forward=False,
reverse=True,
include_hidden=True,
include_parents=False,
# Related fields must be returned in a deterministic order.
return sorted(
model._meta._get_fields(
forward=False,
reverse=True,
include_hidden=True,
include_parents=False,
),
key=operator.attrgetter("name"),
)