From 8e4c15f1dba41b709b4e562f883dc011c59cef65 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 21 Aug 2017 11:49:14 +0200 Subject: [PATCH] Trigger save logic when archiving students through admin action --- stages/admin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stages/admin.py b/stages/admin.py index 2a0c3f2..4adb2fd 100644 --- a/stages/admin.py +++ b/stages/admin.py @@ -81,7 +81,10 @@ class StudentAdmin(admin.ModelAdmin): actions = ['archive'] def archive(self, request, queryset): - queryset.update(archived=True) + for student in queryset: + # Save each item individually to allow for custom save() logic. + student.archived = True + student.save() archive.short_description = "Marquer les étudiants sélectionnés comme archivés" '''def get_readonly_fields(self, request, obj=None):