magic-removal: Changed get_all_related_many_to_many_objects to use caching. Refs #1186. Thanks, Russ
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1855 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b23b39342b
commit
2bc39d88e6
|
@ -166,14 +166,18 @@ class Options:
|
|||
return follow
|
||||
|
||||
def get_all_related_many_to_many_objects(self):
|
||||
module_list = get_installed_model_modules()
|
||||
rel_objs = []
|
||||
for mod in module_list:
|
||||
for klass in mod._MODELS:
|
||||
for f in klass._meta.many_to_many:
|
||||
if f.rel and self == f.rel.to._meta:
|
||||
rel_objs.append(RelatedObject(self, klass, f))
|
||||
return rel_objs
|
||||
try: # Try the cache first.
|
||||
return self._all_related_many_to_many_objects
|
||||
except AttributeError:
|
||||
module_list = get_installed_model_modules()
|
||||
rel_objs = []
|
||||
for mod in module_list:
|
||||
for klass in mod._MODELS:
|
||||
for f in klass._meta.many_to_many:
|
||||
if f.rel and self == f.rel.to._meta:
|
||||
rel_objs.append(RelatedObject(self, klass, f))
|
||||
self._all_related_many_to_many_objects = rel_objs
|
||||
return rel_objs
|
||||
|
||||
def get_ordered_objects(self):
|
||||
"Returns a list of Options objects that are ordered with respect to this object."
|
||||
|
|
Loading…
Reference in New Issue