开发者

Advice on django form change emailing

Goal: On submission of a form to add/update/delete objects an email is sent out with the current contents of the DB object and the new contents of the DB object in html.

Example

Object Title was oldTitle and has been changed to newTitle

Object Date was oldDate and has been changed to newDate

My assumption this can be done two different ways. Directly through send_mail or via signals. My gut leans towards using signals to make sure I can 开发者_开发百科grab previous content and the new content but I am not quite sure if this is the right way to go. Any advice you can give would be much appreciated. I couldn't find very much on this subject online.


Queue up the message to be sent in the pre_save signal, and send (or reap) them in the post_save signal.


Try overriding save() in your model objects, and grabbing the fields in question before calling super().

Here's a database email queue I wrote, which may help you with the actual sending of the mail:

http://gist.github.com/629663

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜