Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obtain Message instance after email send #50

Open
eLRuLL opened this issue Feb 24, 2021 · 0 comments
Open

obtain Message instance after email send #50

eLRuLL opened this issue Feb 24, 2021 · 0 comments

Comments

@eLRuLL
Copy link

eLRuLL commented Feb 24, 2021

I am implementing a Notifications feature and I'd like to connect the notification with the email sent, for that I included something like the following to my Notification model.

email_message = models.OneToOneField(
    djmail_models.Message,
    on_delete=models.SET_NULL,
    null=True,
    blank=True,
    verbose_name=_("Email message"),
)

But I don't know how to later match this, the only thing that I was able to come up with was:

self.email_message = djmail_models.Message.objects.filter(
        body_html__icontains=self.id
    ).first()

But that is not optimal, is there a way to get the uuid or model instance for example when the email is sent? or how should I go about doing this? I send the email this way:

email_builder = template_mail.MagicMailBuilder()
context = {
    ...
}
email = email_builder.notification(self.recipient, context)
email.send() # <---------- it would be cool to have something like "djmail_message = email.send()"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant