【问题标题】:cannot concatenate 'str' and 'WSGIRequest' objects无法连接“str”和“WSGIRequest”对象
【发布时间】:2011-12-06 21:04:54
【问题描述】:

我在尝试加载模板时不断收到此错误:

TypeError: cannot concatenate 'str' and 'WSGIRequest' objects

这里是粘贴的链接:https://gist.github.com/3b7039baf13d91a67de2

您会注意到,从 traceback 中的一行指向我的 views.py 以及下面方法中的最后一行。最后一行可能是问题吗?如果是,我该如何解决它。提前致谢

def all(request):
    """This returns all the photos in the database
    """
    return render_to_response(request, 'photos/all.html', {'photos':
        Photo.objects.all().order_by('-date_added')})

【问题讨论】:

    标签: django django-templates django-views


    【解决方案1】:

    render_to_response 不接受请求作为其第一个参数。

    render,来自 Django 1.3,但是确实如此。也许是您打算使用的方法?

    【讨论】:

    • 谢谢。这解决了我的问题:-)
    猜你喜欢
    • 2013-06-01
    • 2017-08-11
    • 2011-10-23
    • 2015-09-01
    • 2020-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多