Why Django don't cache part of the result when the queryset is partly evaluated?

17 views
Skip to first unread message

胡凯旋

unread,
Oct 17, 2018, 9:04:04 AM10/17/18
to Django users
As official document said, the code will query database twice.
>>> queryset = Entry.objects.all()
>>> print(queryset[5]) # Queries the database
>>> print(queryset[5]) # Queries the database again

 Why don't just cache the record at index 5 of this queryset? When execute queryset[5] again, fetch result from cache rather than database? 

Is there any reason don't cache results of queryset partly? 

Reply all
Reply to author
Forward
0 new messages