I want to send an email after saving the data into a database,but I don't want to wait after completed send email return the HTTP
response ,I want to return the HTTP
response direct ,then send the email by Django self.
def received(request):
login=get_login(request)
received=True
cluster_list=models.Cluster.objects.all()
Asset_Type=models.CategoryOfAsset.objects.all()
if request.method=="GET":
return render(request,"received.html",locals())
if request.is_ajax():
try:
req=json.loads(request.body)
meta_data_dict=req['meta_data']
item_data_dict=req['all_item_data']['item_data']
received_or_shipment=True
insert_meta_item_to_DB(meta_data_dict,item_data_dict,received_or_shipment)
sendTemplateEmail(meta_data_dict,item_data_dict)
return HttpResponse(json.dumps('sucessful'))
except Exception, e:
logger.error(e)
Now the code will cause this error:
ValueError: The view tool.views.received didn't return an HttpResponse object
It returned None instead.