Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8304887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:57:29+00:00 2026-06-08T17:57:29+00:00

views.py from registration.models import Registration from django.core.context_processors import csrf from registration import tasks from

  • 0

views.py

from registration.models import Registration
from django.core.context_processors import csrf
from registration import tasks
from django.shortcuts import render_to_response
def validate(request):
    state="notvalid"
    if request.method == 'POST':# If the form has been submitted...
        form = Registration(request.POST) # A form bound to the POST data
        state="notvalid"
        if form.is_valid(): 
            username = form.cleaned_data['username']
            first_name = form.cleaned_data['first_name']
            last_name = form.cleaned_data['last_name']
            email = form.cleaned_data['email']
            password = form.cleaned_data['password']
            from django.contrib.auth.models import User
            user = User.objects.create_user(username,email,password)
            user.first_name=first_name
            user.last_name=last_name        
            user.save() 
            state="added data"
        tasks.mail()
    else:
        form = Registration() # An unbound form

    return render_to_response('auth1.html', {
        'form': form,'state':state,
    })

tasks.py

from celery import task
import celery

@celery.task()
def mail():
    from django.core.mail import send_mail
    for x in range(10000000):
        print x
    return True

the task has to be performed parrelel without affecting the time of views response. I.e
in background it has to run mail function

but after database adding it hase to return render_to_response

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:57:30+00:00Added an answer on June 8, 2026 at 5:57 pm

    Your call to trigger the mail task should be:

    tasks.mail.delay()
    

    Without the delay(), the task will run in the same process as the view, not in a Celery worker, and so the view function will block until mail is finished.

    See http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html#calling-our-task for more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

# settings.py EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' # view.py from django.core.mail import send_mail def send_letter(request): the_text
I have installed django-registration with pip, version 0.7. Then with urls.py from core.forms import
here is my code: urls.py: from django.conf.urls import patterns from views import show,showpage urlpatterns
My Models.py, Here I'm using OneToOneField here, to extend StudentProfile. from django.db import models
Django Endless Pagination works perfectly fine right until I use template inheritance. views.py: from
I am writing a GUI application using Django 1.1.1. This is the views.py: from
I am trying to use Django's generic views to make a user registration page.
I want opinion and views from community. I am developing a large application with
We are investigating how to create data entry views from a dynamic list of
I was wondering if is there an easy way to generate views from form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.