Ticket #7151: 7151-patch1.diff

File 7151-patch1.diff, 2.1 KB (added by trbs, 7 years ago)
  • django/contrib/admin/views/main.py

    diff -r 45a65187860f django/contrib/admin/views/main.py
    a b  
    716716                        qs = qs.select_related()
    717717                        break
    718718
     719<<<<<<< local
     720        # Calculate lookup_order_field.
     721        # If the order-by field is a field with a relationship, order by the
     722        # value in the related table.
     723        lookup_order_field = self.order_field
     724        try:
     725            f = self.lookup_opts.get_field(self.order_field, many_to_many=False)
     726        except models.FieldDoesNotExist:
     727            pass
     728        else:
     729            if isinstance(f.rel, models.OneToOneRel):
     730                # For OneToOneFields, don't try to order by the related object's ordering criteria.
     731                pass
     732            elif isinstance(f.rel, models.ManyToOneRel):
     733                rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column
     734                lookup_order_field = '%s__%s' % (f.name, rel_ordering)
     735
     736=======
     737>>>>>>> other
    719738        # Set ordering.
    720739        if self.order_field:
    721740            qs = qs.order_by('%s%s' % ((self.order_type == 'desc' and '-' or ''), self.order_field))
  • django/core/management/__init__.py

    diff -r 45a65187860f django/core/management/__init__.py
    a b  
    194194            options, args = parser.parse_args(self.argv)
    195195            handle_default_options(options)
    196196        except:
    197             pass # Ignore any option errors at this point.
     197            args = None # Ignore any option errors at this point.
    198198
    199199        try:
    200200            subcommand = self.argv[1]
     
    203203            sys.exit(1)
    204204
    205205        if subcommand == 'help':
    206             if len(args) > 2:
     206            if not args is None and len(args) > 2:
    207207                self.fetch_command(args[2]).print_help(self.prog_name, args[2])
    208208            else:
    209209                sys.stderr.write(self.main_help_text() + '\n')
Back to Top