Code

Ticket #7151: 7151-patch1.diff

File 7151-patch1.diff, 2.1 KB (added by trbs, 6 years ago)
Line 
1diff -r 45a65187860f django/contrib/admin/views/main.py
2--- a/django/contrib/admin/views/main.py        Wed Apr 30 00:03:45 2008 +0000
3+++ b/django/contrib/admin/views/main.py        Thu May 01 20:05:01 2008 +0200
4@@ -716,6 +716,25 @@
5                         qs = qs.select_related()
6                         break
7 
8+<<<<<<< local
9+        # Calculate lookup_order_field.
10+        # If the order-by field is a field with a relationship, order by the
11+        # value in the related table.
12+        lookup_order_field = self.order_field
13+        try:
14+            f = self.lookup_opts.get_field(self.order_field, many_to_many=False)
15+        except models.FieldDoesNotExist:
16+            pass
17+        else:
18+            if isinstance(f.rel, models.OneToOneRel):
19+                # For OneToOneFields, don't try to order by the related object's ordering criteria.
20+                pass
21+            elif isinstance(f.rel, models.ManyToOneRel):
22+                rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column
23+                lookup_order_field = '%s__%s' % (f.name, rel_ordering)
24+
25+=======
26+>>>>>>> other
27         # Set ordering.
28         if self.order_field:
29             qs = qs.order_by('%s%s' % ((self.order_type == 'desc' and '-' or ''), self.order_field))
30diff -r 45a65187860f django/core/management/__init__.py
31--- a/django/core/management/__init__.py        Wed Apr 30 00:03:45 2008 +0000
32+++ b/django/core/management/__init__.py        Thu May 01 20:05:01 2008 +0200
33@@ -194,7 +194,7 @@
34             options, args = parser.parse_args(self.argv)
35             handle_default_options(options)
36         except:
37-            pass # Ignore any option errors at this point.
38+            args = None # Ignore any option errors at this point.
39 
40         try:
41             subcommand = self.argv[1]
42@@ -203,7 +203,7 @@
43             sys.exit(1)
44 
45         if subcommand == 'help':
46-            if len(args) > 2:
47+            if not args is None and len(args) > 2:
48                 self.fetch_command(args[2]).print_help(self.prog_name, args[2])
49             else:
50                 sys.stderr.write(self.main_help_text() + '\n')