Skip to content

Commit

Permalink
magic-removal: fixed #1245. For models with a OneToOneField and no or…
Browse files Browse the repository at this point in the history
…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
jkocherhans committed Apr 21, 2006
1 parent 9d2992b commit 0121e4c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion django/contrib/admin/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0121e4c

Please sign in to comment.