Ticket #34802: admin-counts-message.patch

File admin-counts-message.patch, 1.3 KB (added by Wicher Minnaard, 15 months ago)
  • actions.py

    diff -Naur admin.old/actions.py admin/actions.py
    old new  
    4848            for obj in queryset:
    4949                obj_display = str(obj)
    5050                modeladmin.log_deletion(request, obj, obj_display)
    51             modeladmin.delete_queryset(request, queryset)
     51            actually_deleted_count = modeladmin.delete_queryset(request, queryset)
     52            if actually_deleted_count is not None:
     53                n = actually_deleted_count
    5254            modeladmin.message_user(
    5355                request,
    5456                _("Successfully deleted %(count)d %(items)s.")
  • options.py

    diff -Naur admin.old/options.py admin/options.py
    old new  
    12331233        obj.delete()
    12341234
    12351235    def delete_queryset(self, request, queryset):
    1236         """Given a queryset, delete it from the database."""
    1237         queryset.delete()
     1236        """
     1237        Given a queryset, delete it from the database.
     1238        Optionally return the number of items deleted.
     1239        """
     1240        actually_deleted_count, _objecttypes = queryset.delete()
     1241        return actually_deleted_count
    12381242
    12391243    def save_formset(self, request, form, formset, change):
    12401244        """
Back to Top