Django

Code

Changeset 2720

Show
Ignore:
Timestamp:
04/21/06 12:04:02 (3 years ago)
Author:
jkocherhans
Message:

magic-removal: fixed #1245. For models with a OneToOneField? and no ordering 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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/django/contrib/admin/views/main.py

    r2700 r2720  
    696696            pass 
    697697        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): 
    699702                rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column 
    700703                lookup_order_field = '%s.%s' % (f.rel.to._meta.db_table, rel_ordering)