Last active
June 7, 2019 17:07
-
-
Save goutomroy/ddceafd847d5218b1da7af6b8515f73f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following will create two QuerySet's, evaluate them, and throw them away | |
# because they are not saving the queryset anywhere to reuse them later. | |
print([e.headline for e in Entry.objects.all()]) | |
print([e.pub_date for e in Entry.objects.all()]) | |
# Following code saves QuerySet in a variable. When it evaluates, | |
# it saves the results to its cache(_result_cache). | |
queryset = Entry.objects.all() | |
# evaluation with iteration. | |
for each in queryset: | |
print(each.headline) | |
# Using cache from previous evaluation. | |
for each in queryset: | |
print(each.id) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment