'An iterator over the results from applying this QuerySet to the
database.'

def iterator(self):

    fill_cache = self.query.select_related
    if isinstance(fill_cache, dict):
        requested = fill_cache
    else:
        requested = None
    max_depth = self.query.max_depth
    extra_select = self.query.extra_select.keys()
    aggregate_select = self.query.aggregate_select.keys()
    only_load = self.query.get_loaded_field_names()
    if (not fill_cache):
        fields = self.model._meta.fields
        pk_idx = self.model._meta.pk_index()
    index_start = len(extra_select)
    aggregate_start = (index_start + len(self.model._meta.fields))
    load_fields = []
    if only_load:
        for (field, model) in self.model._meta.get_fields_with_model():
            if (model is None):
                model = self.model
            if (field == self.model._meta.pk):
                pk_idx = len(load_fields)
            try:
                if (field.name in only_load[model]):
                    load_fields.append(field.name)
            except KeyError:
                load_fields.append(field.name)
    skip = None
    if (load_fields and (not fill_cache)):
        skip = set()
        init_list = []
        for field in fields:
            if (field.name not in load_fields):
                skip.add(field.attname)
            else:
                init_list.append(field.attname)
        model_cls = deferred_class_factory(self.model, skip)
    db = self.db
    model = self.model
    compiler = self.query.get_compiler(using=db)
    for row in compiler.results_iter():
        if fill_cache:
            (obj, _) = get_cached_row(model, row, index_start, using=db, max_depth=max_depth, requested=requested, offset=len(aggregate_select), only_load=only_load)
        else:
            if skip:
                row_data = row[index_start:aggregate_start]
                pk_val = row_data[pk_idx]
                obj = model_cls(**dict(zip(init_list, row_data)))
            else:
                obj = model(*row[index_start:aggregate_start])
            obj._state.db = db
            obj._state.adding = False
        if extra_select:
            for (i, k) in enumerate(extra_select):
                setattr(obj, k, row[i])
        if aggregate_select:
            for (i, aggregate) in enumerate(aggregate_select):
                setattr(obj, aggregate, row[(i + aggregate_start)])
        (yield obj)
