python - Django Admin, Call function on save -
i have app in django site handles blog post. when blog post published want schedule newsletter on third party application informs subscribers of new post.
so want add custom function called when blog post saved can write api call newsletter service.
how this? tried looking through documentations , can find admin actions doesn't seem i'm looking for.
there number of approaches use.
override model save method simple, called every time model saved.
https://docs.djangoproject.com/en/1.8/ref/models/instances/#saving-objects
if specific admin site, in modeladmin use model_save() method. (i approach personally, won't interfere model).
https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.modeladmin.save_model
you use post save signal, save methods seem preferred (depending on doing) django: when customize save vs using post-save signal
Comments
Post a Comment