Here is my post_save method:
from asgiref.sync import sync_to_async
@receiver(post_save, sender=SubmissionDetails)
def create_submission_email(sender, instance, created, **kwargs):
if created:
data = sync_to_async(call_submssion_email(instance))
def call_manuscript_submssion_email(instance):
print("Hi")
message = '''Submitted with the title, <br>
{0}'''.format(instance.title)
subject = 'Article Submitted'
to_address = 'example@gmail.com'
from_address = "from@mail.example.com"
msg = EmailMessage(
subject, message,from_address,[to_address]
)
msg.content_subtype = "html"
msg.send()
The problem is while submitting the form, the user has to wait till email is sent to see the results. I am using django 3.0 with some async support.