Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save goutomroy/221a0f61dc639e3c31c8380b69e94949 to your computer and use it in GitHub Desktop.
Save goutomroy/221a0f61dc639e3c31c8380b69e94949 to your computer and use it in GitHub Desktop.
# The `if` statement evaluates the queryset and saves results in cache.
queryset = Entry.objects.all()
if queryset:
# Using cache from previous if statement evaluation.
for each in queryset:
print(each.headline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment