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

问题描述 投票:0回答:1

为什么我会看到此错误?下面

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)
python django httpresponse
1个回答
2
投票

Django 警告您,在未来的版本中,

HttpResponse
将仅接受字符串作为内容。

data['id'] == 8
的情况下,您将通过
set
。 您可能只需在此处传递一个字符串即可。

如需参考,请参阅文档此处此处

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.