Created
May 2, 2019 21:54
-
-
Save valerybriz/56d64d969dc8232f23f1afa5d43b5973 to your computer and use it in GitHub Desktop.
This file contains 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
user_queryset = User.objects.all() | |
# The first hit to the database confirms if at least one object exists. | |
if user_queryset.exists(): | |
# Another database hit to start fetching the rows in batches. | |
for user in user_queryset.iterator(): | |
print(user.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment