summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2015-02-03 15:13:43 -0500
committerSimon Charette <charette.s@gmail.com>2015-02-03 16:40:31 -0500
commit65e005f8cd9c656e558e53e6c8b890cd0fcc9e74 (patch)
tree99f147451d6fad705dd66e2fbdc4001bcbd23cb0 /django
parent281fc03474ac18c8281ed4cf289128c87bda2030 (diff)
Fixed #24266 -- Changed get_parent_list to return a list ordered by MRO.
Thanks to Aron Podrigal for the initial patch and Tim for the review.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/options.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/django/db/models/options.py b/django/db/models/options.py
index 03470408e0..fa9726556b 100644
--- a/django/db/models/options.py
+++ b/django/db/models/options.py
@@ -12,7 +12,7 @@ from django.db.models.fields.related import ManyToManyField
from django.db.models.fields import AutoField
from django.db.models.fields.proxy import OrderWrt
from django.utils import six
-from django.utils.datastructures import ImmutableList
+from django.utils.datastructures import ImmutableList, OrderedSet
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, smart_text, python_2_unicode_compatible
from django.utils.functional import cached_property
@@ -634,14 +634,14 @@ class Options(object):
def get_parent_list(self):
"""
- Returns a list of all the ancestor of this model as a list. Useful for
- determining if something is an ancestor, regardless of lineage.
+ Returns all the ancestors of this model as a list ordered by MRO.
+ Useful for determining if something is an ancestor, regardless of lineage.
"""
- result = set()
+ result = OrderedSet(self.parents)
for parent in self.parents:
- result.add(parent)
- result.update(parent._meta.get_parent_list())
- return result
+ for ancestor in parent._meta.get_parent_list():
+ result.add(ancestor)
+ return list(result)
def get_ancestor_link(self, ancestor):
"""