Code

Opened 9 years ago

Closed 8 years ago

Last modified 7 years ago

#1219 closed defect (fixed)

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

Reported by: jacobkm Owned by: russellm
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: UI/UX:

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 russellm 8 years ago.
Patch implementing bulk delete in post-descriptor magic-removal
bulk-delete-v2.patch (20.0 KB) - added by russellm 8 years ago.
Patch implementing bulk delete in post-descriptor magic-removal

Download all attachments as: .zip

Change History (10)

comment:1 Changed 8 years ago by russellm

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 Changed 8 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:3 Changed 8 years ago by russellm

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

comment:4 Changed 8 years ago by hugo

  • Reporter changed from jacob to russelm
  • Resolution fixed deleted
  • Status changed from closed to reopened

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 Changed 8 years ago by hugo

  • Owner changed from adrian to russelm
  • Reporter changed from russelm to jacobkm
  • Status changed from reopened to new

comment:6 Changed 8 years ago by russellm

  • Owner changed from russelm to russellm

Changed 8 years ago by russellm

Patch implementing bulk delete in post-descriptor magic-removal

Changed 8 years ago by russellm

Patch implementing bulk delete in post-descriptor magic-removal

comment:7 Changed 8 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:8 Changed 7 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.