29π
β
oddly, it was returning only a partial
list of books.
Thatβs not how the queryset must work. Iterating over queryset should give you every record returned by your database. Debug your code. Youβll find the error, otherwise debug it again.
Itβs easy to check in the REPL. Run manage.py shell
:
from app.models import Model
for o in Model.objects.filter(fieldname="foo"): print o
#Let's see DB query
from django.db import connection
print(connection.queries)
π€alex vasi
2π
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.
π€Konstantin Popov
- [Django]-Django date format 'dd-mm-yyyy'
- [Django]-How to use Django model inheritance with signals?
- [Django]-How does one make logging color in Django/Google App Engine?
Source:stackexchange.com