code: def iter_qs(qs, adapter):
      '''Safely iterate over a DB QuerySet yielding ES documents'''
      for obj in qs.no_cache().no_dereference().timeout(False):
          if adapter.is_indexable(obj):
              try:
                  doc = adapter.from_model(obj).to_dict(include_meta=True)
                  yield doc
              except Exception as e:
                  model = adapter.model.__name__
                  log.error('Unable to index %s "%s": %s', model, str(obj.id),
                            str(e), exc_info=Truef iter_qs(qs, adapter):
      '''Safely iterate over a DB QuerySet yielding ES documents'''
      for obj in qs.no_cache().no_dereference().timeout(False):
          if adapter.is_indexable(obj):
              try:
                  doc = adapter.from_model(obj).to_dict(include_meta=True)
                  yield doc
              except Exception as e:
                  model = adapter.model.__name__
                  log.error('Unable to index %s "%s": %s', model, str(obj.id),
                            str(e), exc_info=True)
docs: Safely iterate over a DB QuerySet yielding ES documents