'Merge the \'rhs\' query into the current one (with any \'rhs\' effects
being applied *after* (that is, "to the right of") anything in the
current query. \'rhs\' is not modified during a call to this function.
The \'connector\' parameter describes how to connect filters from the
\'rhs\' query.'

def combine(self, rhs, connector):

    assert (self.model == rhs.model), 'Cannot    combine    queries    on    two    different    base    models.'
    assert self.can_filter(), 'Cannot    combine    queries    once    a    slice    has    been    taken.'
    assert (self.distinct == rhs.distinct), 'Cannot    combine    a    unique    query    with    a    non-unique    query.'
    assert (self.distinct_fields == rhs.distinct_fields), 'Cannot    combine    queries    with    different    distinct    fields.'
    change_map = {}
    conjunction = (connector == AND)
    reuse = (set() if conjunction else set(self.alias_map))
    self.get_initial_alias()
    joinpromoter = JoinPromoter(connector, 2, False)
    joinpromoter.add_votes((j for j in self.alias_map if (self.alias_map[j].join_type == INNER)))
    rhs_votes = set()
    rhs_tables = list(rhs.alias_map)[1:]
    for alias in rhs_tables:
        join = rhs.alias_map[alias]
        join = join.relabeled_clone(change_map)
        new_alias = self.join(join, reuse=reuse)
        if (join.join_type == INNER):
            rhs_votes.add(new_alias)
        reuse.discard(new_alias)
        if (alias != new_alias):
            change_map[alias] = new_alias
        if (not rhs.alias_refcount[alias]):
            self.unref_alias(new_alias)
    joinpromoter.add_votes(rhs_votes)
    joinpromoter.update_join_types(self)
    w = rhs.where.clone()
    w.relabel_aliases(change_map)
    self.where.add(w, connector)
    if rhs.select:
        self.set_select([col.relabeled_clone(change_map) for col in rhs.select])
    else:
        self.select = ()
    if (connector == OR):
        if (self._extra and rhs._extra):
            raise ValueError("When    merging    querysets    using    'or',    you    cannot    have    extra(select=...)    on    both    sides.")
    self.extra.update(rhs.extra)
    extra_select_mask = set()
    if (self.extra_select_mask is not None):
        extra_select_mask.update(self.extra_select_mask)
    if (rhs.extra_select_mask is not None):
        extra_select_mask.update(rhs.extra_select_mask)
    if extra_select_mask:
        self.set_extra_mask(extra_select_mask)
    self.extra_tables += rhs.extra_tables
    self.order_by = (rhs.order_by if rhs.order_by else self.order_by)
    self.extra_order_by = (rhs.extra_order_by or self.extra_order_by)
