Code

Ticket #2137: get_ordered_objects_r15376.patch

File get_ordered_objects_r15376.patch, 1.6 KB (added by dokterbob, 3 years ago)

Updated patch for Django SVN r15376

  • options.py

     
    66from django.db.models.fields.related import ManyToManyRel 
    77from django.db.models.fields import AutoField, FieldDoesNotExist 
    88from django.db.models.fields.proxy import OrderWrt 
    9 from django.db.models.loading import get_models, app_cache_ready 
     9from django.db.models.loading import get_models, app_cache_ready, get_apps, get_model 
    1010from django.utils.translation import activate, deactivate_all, get_language, string_concat 
    1111from django.utils.encoding import force_unicode, smart_str 
    1212from django.utils.datastructures import SortedDict 
     
    480480        "Returns a list of Options objects that are ordered with respect to this object." 
    481481        if not hasattr(self, '_ordered_objects'): 
    482482            objects = [] 
    483             # TODO 
    484             #for klass in get_models(get_app(self.app_label)): 
    485             #    opts = klass._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) 
     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)             
    489489            self._ordered_objects = objects 
     490 
    490491        return self._ordered_objects 
    491492 
    492493    def pk_index(self):