Django

Code

Ticket #1219 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

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

Reported by: jacobkm Assigned to: russellm
Milestone: Component: Database layer (models, ORM)
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

bulk-delete.patch (19.4 kB) - added by russellm on 02/11/06 03:08:11.
Patch implementing bulk delete in post-descriptor magic-removal
bulk-delete-v2.patch (20.0 kB) - added by russellm on 02/11/06 08:43:37.
Patch implementing bulk delete in post-descriptor magic-removal

Change History

01/16/06 08:19:56 changed 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?

01/17/06 06:06:23 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

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

01/18/06 07:25:16 changed by russellm

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

01/18/06 16:52:56 changed by hugo

  • status changed from closed to reopened.
  • resolution deleted.
  • reporter changed from jacob to russelm.

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.

01/18/06 16:53:15 changed by hugo

  • owner changed from adrian to russelm.
  • status changed from reopened to new.
  • reporter changed from russelm to jacobkm.

01/18/06 17:36:42 changed by russellm

  • owner changed from russelm to russellm.

02/11/06 03:08:11 changed by russellm

  • attachment bulk-delete.patch added.

Patch implementing bulk delete in post-descriptor magic-removal

02/11/06 08:43:37 changed by russellm

  • attachment bulk-delete-v2.patch added.

Patch implementing bulk delete in post-descriptor magic-removal

02/14/06 03:51:36 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

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

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted


Add/Change #1219 (There's no way to bulk delete a set of objects)




Change Properties
Action