Opened 6 years ago

Closed 6 years ago

#15140 closed (wontfix)

Allow redefining object to delete collector in Django admin

Reported by: Manuel Saelices Owned by: Manuel Saelices
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 Manuel Saelices 6 years ago.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by Manuel Saelices

comment:1 Changed 6 years ago by Manuel Saelices

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 6 years ago by Manuel Saelices

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 6 years ago by Manuel Saelices

Owner: changed from nobody to Manuel Saelices

comment:4 Changed 6 years ago by Alex Gaynor

Why? What's the usecase here.

comment:5 Changed 6 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

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