Reputation: 3424
I am using django 2.0 and python 3.6.
The user registration includes sending of a verification mail. And this mail sending process is taking longer and the user is kept waiting.
What I need?: If the user registration form is valid, mailing details are sent to another task handler and regardless of whether the mail is sent or not, the function must resume and return a response.
def new_user_registration(request):
form = CustomUserCreationForm(request.POST or None)
if form.is_valid():
user = form.save()
send_verification_mail(user) #<= taking more time.
return render(request, 'registration/signup.html')
i.e, the send_verification_mail
must be called asynchronously. How to achieve it?
Note: I am new to django and python.
Upvotes: 6
Views: 1471
Reputation: 4461
Most of the time you will use a task queue for this.
Celery has been around for a long time and it is well known and documented, but recently I'm moving all my stuff to TaskTiger
Upvotes: 3