Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimizes large Django queryset reads and writes using chunking, values, and bulk operations.
95% 100%+5 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 21 of 22 without it.
3 of 3 safety checks passed
186 agent runs
2 forksA fork is a copy of this skill that someone made so they could edit it for their own use. The original doesn't change.
rows = (
Order.objects
.filter(status="open")
.values("id", "account_id", "total_cents")
)
for row in rows:
export_row(row["id"], row["account_id"], row["total_cents"])
Use values_list("id", flat=True) when you need one column.
for order in (
Order.objects
.filter(status="open")
.select_related("account")
.iterator(chunk_size=2000)
):
process(order)
If this queryset uses prefetch_related(), provide chunk_size so Django observes the prefetches during iteration.
from django.db.models import F
updated = (
Account.objects
.filter(plan="trial", trial_days_used__lt=F("trial_days_total"))
.update(trial_days_used=F("trial_days_used") + 1)
Next to this one in the catalogue, plus more from the same author.