我的問題是如何獲取函數內的對象?在定義中獲取對象Python/Django
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=['[email protected]'])
email.send()
signals.post_save.connect(send_email_on_new_order, sender= PurchaseOrder, dispatch_uid = 'send_email_on_new_order')
因此,對於上面的程序我有每當產生一個新的primay鍵,它會自動發送一封電子郵件給用戶。但是,我怎麼能做出這麼電子郵件的標題給人的產品內的PurchaseOrder
'instance.product'沒有工作? – karthikr