MCPcopy
hub / github.com/django/django / iterator

Method iterator

django/db/models/query.py:560–577  ·  view source on GitHub ↗

An iterator over the results from applying this QuerySet to the database. chunk_size must be provided for QuerySets that prefetch related objects. Otherwise, a default chunk_size of 2000 is supplied.

(self, chunk_size=None)

Source from the content-addressed store, hash-verified

558 yield from results
559
560 def iterator(self, chunk_size=None):
561 """
562 An iterator over the results from applying this QuerySet to the
563 database. chunk_size must be provided for QuerySets that prefetch
564 related objects. Otherwise, a default chunk_size of 2000 is supplied.
565 """
566 if chunk_size is None:
567 if self._prefetch_related_lookups:
568 raise ValueError(
569 "chunk_size must be provided when using QuerySet.iterator() after "
570 "prefetch_related()."
571 )
572 elif chunk_size <= 0:
573 raise ValueError("Chunk size must be strictly positive.")
574 use_chunked_fetch = not connections[self.db].settings_dict.get(
575 "DISABLE_SERVER_SIDE_CURSORS"
576 )
577 return self._iterator(use_chunked_fetch, chunk_size)
578
579 async def aiterator(self, chunk_size=2000):
580 """

Callers 6

queryset_iteratorMethod · 0.45
queryset_iteratorMethod · 0.45
get_objectsMethod · 0.45
__iter__Method · 0.45
_get_choicesMethod · 0.45
get_objectsMethod · 0.45

Calls 2

_iteratorMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected