Ticket #27326: modeladmin_delete_queryset.diff

File modeladmin_delete_queryset.diff, 1.2 KB (added by Dimitris Glynos, 8 years ago)

ModelAdmin delete_queryset git diff (affects options.py and actions.py)

  • django/contrib/admin/actions.py

    diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py
    index 6fdf070..4f293d1 100644
    a b def delete_selected(modeladmin, request, queryset):  
    4646            for obj in queryset:
    4747                obj_display = force_text(obj)
    4848                modeladmin.log_deletion(request, obj, obj_display)
    49             queryset.delete()
     49            modeladmin.delete_queryset(request, queryset)
    5050            modeladmin.message_user(request, _("Successfully deleted %(count)d %(items)s.") % {
    5151                "count": n, "items": model_ngettext(modeladmin.opts, n)
    5252            }, messages.SUCCESS)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 499d27d..71dd5c1 100644
    a b class ModelAdmin(BaseModelAdmin):  
    982982        """
    983983        obj.delete()
    984984
     985    def delete_queryset(self, request, queryset):
     986        """
     987        Given a queryset instance delete it from the database.
     988        """
     989        queryset.delete()
     990
    985991    def save_formset(self, request, form, formset, change):
    986992        """
    987993        Given an inline formset save it to the database.
Back to Top