Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

magic-removal: fixed #1245. For models with a OneToOneField and no or…

…dering specified, the admin change_list now orders by the OneToOneField rather than trying to order by the related object's ordering. Use the ordering and list_select_related options to do otherwise.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2720 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0121e4cc949e503a695a685cd51fb626cc998864 1 parent 9d2992b
Joseph Kocherhans authored April 21, 2006

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  django/contrib/admin/views/main.py
5  django/contrib/admin/views/main.py
@@ -695,7 +695,10 @@ def get_query_set(self):
695 695
         except models.FieldDoesNotExist:
696 696
             pass
697 697
         else:
698  
-            if isinstance(f.rel, models.ManyToOneRel):
  698
+            if isinstance(f.rel, models.OneToOneRel):
  699
+                # For OneToOneFields, don't try to order by the related object's ordering criteria.
  700
+                pass
  701
+            elif isinstance(f.rel, models.ManyToOneRel):
699 702
                 rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column
700 703
                 lookup_order_field = '%s.%s' % (f.rel.to._meta.db_table, rel_ordering)
701 704
 

0 notes on commit 0121e4c

Please sign in to comment.
Something went wrong with that request. Please try again.