【问题标题】:Django throws error 'WSGIRequest' object has no attribute 'push'Django 抛出错误 'WSGIRequest' 对象没有属性 'push'
【发布时间】:2015-01-09 13:10:53
【问题描述】:

当我运行 django 服务器并加载它说的索引页面时...

错误:

'WSGIRequest' object has no attribute 'push'.

这是我的代码

def index(request):
    context_dict = {'boldmessage': "anything can b written here"}
    return render_to_response('rango/index.html', context_dict, request)

【问题讨论】:

    标签: python django wsgi render-to-response


    【解决方案1】:

    remove时remove请求..应该是

    return render_to_response('rango/index.html',context_dict)
    

    或者使用渲染代替

    return render(request, 'rango/index.html', context_dict)
    

    注意:

    render() 与使用强制使用 RequestContext 的 context_instance 参数调用 render_to_response() 相同。

    【讨论】:

    • 谢谢 rajasimon。它奏效了。我不能投票给你的答案,因为我正在运行某种声誉。:-)
    • @user2728494 如果这个或任何答案已经解决了您的问题,请考虑通过单击复选标记接受它。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。没有义务这样做。
    猜你喜欢
    • 1970-01-01
    • 2019-01-19
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-05
    • 2018-06-14
    相关资源
    最近更新 更多