As official document <https://docs.djangoproject.com/en/2.1/topics/db/queries/#caching-and-querysets> 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? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/067a1251-955b-4cd0-a148-358179104729%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.