A
A
Alexander2016-04-15 15:31:14
Django
Alexander, 2016-04-15 15:31:14

How to disable deletion confirmation?

I found a popular method on the net, but for some reason it does not work

from django.contrib import admin
from poliv.Libary.Upload import save_files
from products.forms import ProductForm
from products.models import Product
def delete_selected(modeladmin, request, queryset):
    queryset.delete()
class ProductAdmin(admin.ModelAdmin):
    actions = (delete_selected,)
    readonly_fields = ('admin_image',)
    list_display = ("title", "category", "status", "short_text")
    list_editable = ("status", "category",)
    prepopulated_fields = {"alias": ("title",)}
    form = ProductForm
    def save_model(self, request, obj, form, change):
        obj.save()
        new_obj = Product.objects.latest('id')
        image = request.FILES.getlist('image')
        save_files(image, 'product', new_obj.id)
admin.site.register(Product, ProductAdmin)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2016-04-15
@fox_12

Please describe your question in more detail. It is not clear what you want to remove there and what does not work for you there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question