Ticket #15819: non-unique-related-fields-distinct4.diff

File non-unique-related-fields-distinct4.diff, 696 bytes (added by johnfink8, 13 years ago)
  • django/contrib/admin/util.py

     
    1616    """
    1717    Returns True if 'distinct()' should be used to query the given lookup path.
    1818    """
    19     field_name = lookup_path.split('__', 1)[0]
     19    paths=lookup_path.split('__')
     20    # If we're more than one join deep, there's a very good chance for dupes
     21    if len(paths)>2:
     22        return True
     23    field_name = paths[0]
    2024    field = opts.get_field_by_name(field_name)[0]
    2125    if ((hasattr(field, 'rel') and
    2226         isinstance(field.rel, models.ManyToManyRel)) or
Back to Top