but this code does not work... keep error message like 'TypeError at /blog/create/
Here are the codes I put at blog/signals.py
@receiver(signals.post_save, sender=Post)
def send_mail(sender, instance, created, **kwargs):
print('signal send')
subject = "Thank you"
message = Post.objects.get(??)
send_mail(subject, 'message', '',
['info@*****.com.au'], fail_silently=False, )
?? is the problem... I put pk=pk, pk=id, I don't know what parameter I need to put here...
You don't need to explicitly get the Post
, you already have it as the instance
parameter sent to the signal (as per the docs):
instance
The actual instance being saved.