Opened 5 years ago

Closed 5 years ago

#15140 closed (wontfix)

Allow redefining object to delete collector in Django admin

Reported by: msaelices Owned by: msaelices
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


ModelAdmin should be able to redefining easily the objects to delete collector.

Attachments (1)

customizable_objects_to_delete_collector_r15256.diff (4.0 KB) - added by msaelices 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by msaelices

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

With this patch you can do something like this:

class FooModelAdmin(admin.ModelAdmin):
    # ...
    def delete_view(self, request, object_id, extra_context=None):
        # ...

        (deleted_objects, perms_needed, protected) = get_deleted_objects(
            [obj], opts, request.user, self.admin_site, using,

        # ...

comment:2 Changed 5 years ago by msaelices

Note that the only lines I've changed in patch was this:

def get_deleted_objects(objs, opts, user, admin_site, using):
    """ ... """
    collector = NestedObjects(using=using)

To this:

def get_deleted_objects(objs, opts, user, admin_site, using, collector_class=NestedObjects):
    """ ... """
    collector = collector_class(using=using)

The other changes (marked in green and red in patch) are due because I have to move up the NestedObjects implementation to be accesible by the get_deleted_objects function.

comment:3 Changed 5 years ago by msaelices

  • Owner changed from nobody to msaelices

comment:4 Changed 5 years ago by Alex

Why? What's the usecase here.

comment:5 Changed 5 years ago by russellm

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

I'm with Alex - I don't see the use case here. THe list of objects to be deleted isn't a matter of debate or control; it's a direct consequence of the delete cascading rules.

If you want to advocate for this change, please start a discussion on django-dev.

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