[Answer]-Django admin editable field – take action

1πŸ‘

βœ…

Yes, this is possible by overriding the save_model method on the ModelAdmin class. You can find the relevant docs here.

So, given your example, you might do something along the lines of this:

from django.contrib import admin

class ArticleAdmin(admin.ModelAdmin):
    def save_model(self, request, obj, form, change):
        if obj.BooleanModelFieldName == True:
            send_email(object.user.email)
        obj.save()

You will probably want to ensure the email does not get sent every time the model is saved by including more precise logic within the method, however.

πŸ‘€user1428660

Leave a comment