#

Using generator for django queryset

Posted on: November 1st 2019, 3:20:42 pm
from book.models import Book

for book in Book.objects.all().iterator()
    book.delete()

Why iterator?

Python wont load all the results in memory. This is used for memory management.