'Helper method for get_order_by() and get_distinct().
get_ordering() and get_distinct() must produce same target columns on
same input, as the prefixes of get_ordering() and get_distinct() must
match. Executing SQL where this is not true is an error.'

def _setup_joins(self, pieces, opts, alias):

    if (not alias):
        alias = self.query.get_initial_alias()
    (field, targets, opts, joins, path) = self.query.setup_joins(pieces, opts, alias)
    alias = joins[(-1)]
    return (field, targets, alias, joins, path, opts)
