Opened 13 years ago

Closed 13 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: no UI/UX: no

Description

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 13 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Manuel Saelices, 13 years ago

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,
            collector_class=CustomNestedObjects)

        # ...

comment:2 by Manuel Saelices, 13 years ago

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

Owner: changed from nobody to Manuel Saelices

comment:4 by Alex Gaynor, 13 years ago

Why? What's the usecase here.

comment:5 by Russell Keith-Magee, 13 years ago

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