Нашёл в нэти самы популярный способ но, он почему не работает
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)