I want to send verification email to new users. But because of slow connection it takes a long time to send an email and user will see a CONNECTION TIMED OUT
error. I want to return the response to user and after that send the email. I already tried StreamingHttpResponse
and using yield
. But it returned a creepy response instead of the response I wanted.
I prefer to do it using function view
but there is no problem if I HAVE to use class view
. What should I do?
from django.shortcuts import render
from django.http import HttpRequest
def sign_up (request: HttpResponse):
method = request.method
if method == 'GET':
# checking cookies
return render(request, "template name", context)
if method == 'POST':
# validating data
if unvalid_data:
return render(request, "template name", context)
# saving data
return render(request, "template name", context)
# sending email