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)
| 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 | """ |
no test coverage detected