Ticket #2137: get_ordered_objects_r15376.patch
File get_ordered_objects_r15376.patch, 1.6 KB (added by , 14 years ago) |
---|
-
options.py
6 6 from django.db.models.fields.related import ManyToManyRel 7 7 from django.db.models.fields import AutoField, FieldDoesNotExist 8 8 from django.db.models.fields.proxy import OrderWrt 9 from django.db.models.loading import get_models, app_cache_ready 9 from django.db.models.loading import get_models, app_cache_ready, get_apps, get_model 10 10 from django.utils.translation import activate, deactivate_all, get_language, string_concat 11 11 from django.utils.encoding import force_unicode, smart_str 12 12 from django.utils.datastructures import SortedDict … … 480 480 "Returns a list of Options objects that are ordered with respect to this object." 481 481 if not hasattr(self, '_ordered_objects'): 482 482 objects = [] 483 # TODO484 #for klass in get_models(get_app(self.app_label)):485 # opts = klass._meta486 #if opts.order_with_respect_to and opts.order_with_respect_to.rel \487 #and self == opts.order_with_respect_to.rel.to._meta:488 # objects.append(opts)483 for app in get_apps(): 484 for model in get_models(app): 485 opts = model._meta 486 if opts.order_with_respect_to and opts.order_with_respect_to.rel \ 487 and self == opts.order_with_respect_to.rel.to._meta: 488 objects.append(opts) 489 489 self._ordered_objects = objects 490 490 491 return self._ordered_objects 491 492 492 493 def pk_index(self):