Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1219 closed defect (fixed)

There's no way to bulk delete a set of objects

Reported by: jacobkm Owned by: Russell Keith-Magee
Component: Database layer (models, ORM) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Ned Batchelder wrote to django-users:

> I'm used to writing SQL statements like:
> 
>    delete from app_things where type = 'foo';
> 
> to delete a number of objects at once.  I don't see a way to do this
> type of delete in Django. I was hoping for something like:
> 
>    things.delete(type__exact='foo')
> 
> Certainly I could do this:
> 
>    for t in things.get_list(type__exact='foo'):
>       t.delete()
> 
> but this incurs a lot more database activity.

Attachments (2)

bulk-delete.patch (19.4 KB ) - added by Russell Keith-Magee 19 years ago.
Patch implementing bulk delete in post-descriptor magic-removal
bulk-delete-v2.patch (20.0 KB ) - added by Russell Keith-Magee 19 years ago.
Patch implementing bulk delete in post-descriptor magic-removal

Download all attachments as: .zip

Change History (10)

comment:1 by Russell Keith-Magee, 19 years ago

Here's a patch against magic-removal that adds bulk delete to the Manager for a model class. Is this approach going to get obsoleted by the descriptor work?

comment:2 by Russell Keith-Magee, 19 years ago

Resolution: fixed
Status: newclosed

(In [2029]) magic-removal: Fixed #1219 - Added bulk delete for objects.

comment:3 by Russell Keith-Magee, 19 years ago

(In [2048]) magic-removal: Refs #1219 -- added documentation for bulk delete feature.

comment:4 by hugo, 19 years ago

Reporter: changed from Jacob to russelm
Resolution: fixed
Status: closedreopened

I reopen this ticket because of the different behaviour of bulk delete and object delete with regard to related objects and relation tables for ManyToMany. See this discussion in django-users.

comment:5 by hugo, 19 years ago

Owner: changed from Adrian Holovaty to russelm
Reporter: changed from russelm to jacobkm
Status: reopenednew

comment:6 by Russell Keith-Magee, 19 years ago

Owner: changed from russelm to Russell Keith-Magee

by Russell Keith-Magee, 19 years ago

Attachment: bulk-delete.patch added

Patch implementing bulk delete in post-descriptor magic-removal

by Russell Keith-Magee, 19 years ago

Attachment: bulk-delete-v2.patch added

Patch implementing bulk delete in post-descriptor magic-removal

comment:7 by Russell Keith-Magee, 19 years ago

Resolution: fixed
Status: newclosed

(In [2307]) magic-removal: Fixed #1219 -- Added implementation of bulk delete, and factored common deletion code out of individual models.

comment:8 by (none), 18 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top