Reputation: 1926
I have a queryset which I iterate through in a loop. I use data from the queryset to change data inside the queryset which might be needed in a lter step of the loop.
Now the queryset is only loaded once at the beginning of the loop. How can I make django reload the data in every iteration?
Upvotes: 0
Views: 55
Reputation: 734
You can reload each object in the start of the loop body. Just use TheModel.objects.get(pk=curr_instance.pk) to do this.
Upvotes: 1