我的问题是如何在函数中获取对象?
class PurchaseOrder(models.Model):
product = models.CharField(max_length=256)
vendor = models.CharField(max_length=256)
def send_email_on_new_order(instance, created, raw, **kwargs):
if not created or raw:
return
email=EmailMessage('NEW Purchase Order System', 'message', to=['dason30@gmail.com'])
email.send()
signals.post_save.connect(send_email_on_new_order, sender= PurchaseOrder, dispatch_uid = 'send_email_on_new_order')
因此,对于上述程序,每当生成新的主键时,我都会自动向用户发送一封电子邮件。但是,我怎样才能使电子邮件的标题在PurchaseOrder中提供产品