开发者

hook django admin change-list editable save button

开发者 https://www.devze.com 2023-01-22 19:18 出处:网络
We are using list-editable list to edit some fields of our model in开发者_运维技巧 the change list itself. However, we currently need to hook the save button of the change list to do some stuff on the

We are using list-editable list to edit some fields of our model in开发者_运维技巧 the change list itself. However, we currently need to hook the save button of the change list to do some stuff on the changed models. Is there a hook for that?

Thanks,


Well, since it has been a while with no response I will give some clues. I had to figure this one out myself. If you look at the HTML generated by the admin for an editable list it provides the "Save" button with the name="_save". So in your admin if you override the changelist_view method:

def changelist_view(self,request,extra_context):
   if request.POST.has_key("_save"):
       #Do something to if save was clicked.
       pass
return admin.ModelAdmin.changelist_view(self,request,extra_context)

you can then add functionality to the save routine.

0

精彩评论

暂无评论...
验证码 换一张
取 消