Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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: http://code.djangoproject.com/svn/django/branches/magic-removal@2720 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0121e4cc949e503a695a685cd51fb626cc998864 1 parent 9d2992b
@jkocherhans jkocherhans authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 django/contrib/admin/views/main.py
View
5 django/contrib/admin/views/main.py
@@ -695,7 +695,10 @@ def get_query_set(self):
except models.FieldDoesNotExist:
pass
else:
- 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 = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column
lookup_order_field = '%s.%s' % (f.rel.to._meta.db_table, rel_ordering)
Please sign in to comment.
Something went wrong with that request. Please try again.