Login

Tag "foreach"

Snippet List

Queryset Foreach

Call a function for each element in a queryset (actually, any list). Features: * stable memory usage (thanks to Django paginators) * progress indicators * wraps batches in transactions * can take managers or even models (e.g., `Assertion.objects`) * warns about `DEBUG`. * handles failures of single items without dying in general. * stable even if items are added or removed during processing (gets a list of ids at the start) Returns a `Status` object, with the following interesting attributes * `total`: number of items in the queryset * `num_successful`: count of successful items * `failed_ids`: list of ids of items that failed

  • queryset
  • progress
  • callback
  • map
  • foreach
  • iterator
Read More

1 snippet posted so far.