def lookup_needs_distinct(opts, lookup_path):
 field_name = lookup_path.split('__', 1)[0]
 field = opts.get_field(field_name)
 if ((hasattr(field, 'rel') and isinstance(field.rel, models.ManyToManyRel)) or (is_related_field(field) and (not field.field.unique))):
  return True
 return False

def lookup_needs_distinct ( opts , lookup_path ) : field_name = lookup_path . split ( '__' , 1 ) [ 0 ] field = opts . get_field ( field_name ) if ( ( hasattr ( field , 'rel' ) and isinstance ( field . rel , models . ManyToManyRel ) ) or ( is_related_field ( field ) and ( not field . field . unique ) ) ) : return True return False
returns true if distinct() should be used to query the given lookup path .