'If the model that is the basis for this QuerySet inherits other models,
we need to ensure that those other models have their tables included in
the query.
We do this as a separate step so that subclasses know which
tables are going to be active in the query, without needing to compute
all the select columns (this method is called from pre_sql_setup(),
whereas column determination is a later part, and side-effect, of
as_sql()).'

def setup_inherited_models(self):

    opts = self.get_meta()
    root_alias = self.tables[0]
    seen = {None: root_alias}
    for (field, model) in opts.get_fields_with_model():
        if (model not in seen):
            self.join_parent_model(opts, model, root_alias, seen)
    self.included_inherited_models = seen
