-1
views.py방법 수있는 몇 가지 기능을 수행하는 내보기 리턴 응답 parrallely
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
작업이보기 응답 시간에 영향을주지 않고 parrelel을 수행 할 수 있습니다. 이 메일 기능을 실행하는 백그라운드에서 즉 는
하지만 데이터베이스가 트리거에는 render_to_response에게
무엇이 잘못 되었나요? –