DeprecationWarning:不推荐使用`HttpResponse`创建流式响应。使用`StreamingHttpResponse`?

时间:2016-04-13 05:30:21

标签: python django httpresponse

为什么我看到这个错误?下面的django方法有问题吗?

def email_send(request):

    data = json.loads(request.body)

    email_conf = getEmailConf(data)
    mail_message = getFormattedMsg(data)
    try:
        t = threading.Thread(target=send_mail,args=[email_conf['subject'],mail_message , email_conf['from_addr'],[email_conf['to_addr'],]],kwargs={'fail_silently':False})
        t.setDaemon(True)
        t.start()
    except:
        print "Exception in sending Mail:"
        print data
        print email_conf
    response= email_conf['response']
    try:
        if data['id']==8:
            response={'redirect2thankupage'}
    except:
        pass
    return HttpResponse(response)

1 个答案:

答案 0 :(得分:2)

Django 警告您,在将来的版本中,HttpResponse只接受字符串作为内容。

如果您data['id'] == 8传递了set。你可以在这里传递一个字符串。

供参考,请参阅文档herehere