Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

queryset-refactor: Removed another FIXME.

This time, simplifying the delete() method.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c23436be59b4a5c3b399a8849812594bd396e419 1 parent 04a55d6
@malcolmt malcolmt authored
Showing with 4 additions and 11 deletions.
  1. +4 −11 django/db/models/
15 django/db/models/
@@ -218,7 +218,6 @@ def in_bulk(self, id_list):
qs.query.add_filter(('pk__in', id_list))
return dict([(obj._get_pk_val(), obj) for obj in qs.iterator()])
- # XXX Mostly DONE
def delete(self):
Deletes the records in the current QuerySet.
@@ -234,22 +233,16 @@ def delete(self):
# Delete objects in chunks to prevent the list of related objects from
# becoming too long.
- more_objects = True
- while more_objects:
+ while 1:
# Collect all the objects to be deleted in this chunk, and all the
# objects that are related to the objects that are to be deleted.
seen_objs = SortedDict()
- more_objects = False
for object in del_query[:CHUNK_SIZE]:
- more_objects = True
- # If one or more objects were found, delete them.
- # Otherwise, stop looping.
- # FIXME: Does "if seen_objs:.." work here? If so, we can get rid of
- # more_objects.
- if more_objects:
- delete_objects(seen_objs)
+ if not seen_objs:
+ break
+ delete_objects(seen_objs)
# Clear the result cache, in case this QuerySet gets reused.
self._result_cache = None
Please sign in to comment.
Something went wrong with that request. Please try again.