Browse files

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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 9d2992b commit 0121e4cc949e503a695a685cd51fb626cc998864 @jkocherhans jkocherhans committed Apr 21, 2006
Showing with 4 additions and 1 deletion.
  1. +4 −1 django/contrib/admin/views/
@@ -695,7 +695,10 @@ def get_query_set(self):
except models.FieldDoesNotExist:
- if isinstance(f.rel, models.ManyToOneRel):
+ if isinstance(f.rel, models.OneToOneRel):
+ # For OneToOneFields, don't try to order by the related object's ordering criteria.
+ pass
+ elif isinstance(f.rel, models.ManyToOneRel):
rel_ordering = and[0] or
lookup_order_field = '%s.%s' % (, rel_ordering)

0 comments on commit 0121e4c

Please sign in to comment.