usage of iterator() on django queryset

后端 未结 2 1775
难免孤独
难免孤独 2021-02-12 14:57

I came across some strange behaviour recently, and need to check my understanding.

I\'m using a simple filter in the model and then iterating over the results.

e

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-12 15:12

    A QuerySet typically caches its results internally so that repeated evaluations do not result in additional queries. In contrast, iterator() will read results directly, without doing any caching at the QuerySet level.

    https://docs.djangoproject.com/en/dev/ref/models/querysets/

提交回复
热议问题