I have a model into I send an email each time this model is edited, with post_save, nice!
I can recover fields from my model to display them in the email, good.
But I would display information about the user connected, logged (username...). I tried some syntaxes, without success, please can you help me?
In model.py, at the end of my model related:
@receiver(post_save, sender=User)
def save(self, **kwargs):
text = 'Hello\n%s %s has just been edited.' % (self.first_name, self.last_name)
my_from = 'webmaster@hg-map.fr'
my_subject = 'Prospect Edit (from test instance, home)'
email = EmailMessage(my_subject, text, my_from, to=['xxx@xxx.fr'])
email.send()