Created
July 29, 2020 14:26
-
-
Save rrei/d42728d666bbcab37fd989d14e43ea8a to your computer and use it in GitHub Desktop.
Basic formulation of the problem
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
def do_stuff(obj): | |
"""Performs some simple processing on `obj`.""" | |
obj.y = obj.related_obj.x ** 2 + 1 # DB query to fetch `.related_obj` | |
obj.save() # DB query to update `obj` | |
# Obtain a large queryset for this example. | |
qs = MyFurstModel.objects.all() | |
# Simply iterate over the queryset and do some processing on each element. | |
# Sounds simple enough, right? WRONG! | |
for obj in qs: | |
do_stuff(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment