【问题标题】:AttributeError at / 'tuple' object has no attribute 'get' in Django/'tuple'对象的AttributeError在Django中没有属性'get'
【发布时间】:2017-02-18 21:53:06
【问题描述】:

我在 / 'tuple' 对象有一个 AttributeError 没有属性 'get',下面是跟踪路径在 Django 中可能有什么问题?

AttributeError at /

'tuple' object has no attribute 'get'

Request Method:     GET
Request URL:    http://www.example.com/
Django Version:     1.10.5
Exception Type:     AttributeError
Exception Value:    

'tuple' object has no attribute 'get'

Exception Location:     /home/admin/env/lib/python3.5/site-packages     /django/middleware/clickjacking.py in process_response, line 32

Python 可执行文件:/home/admin/env/bin/python Python 版本:3.5.2

【问题讨论】:

标签: python django


【解决方案1】:

点击劫持中间件正在调用响应的get 方法。因此,您的视图不会返回 HttpResponse 实例。

【讨论】:

  • 我该如何解决这个问题?我的观点只是在做“return render(request, my.html')”
  • 您检查您的视图代码并确保它返回一个。可能你返回(request, 'template.html') 而不是render(request, 'template.html') 或类似的东西。
  • 您可以在问题中发布您的视图代码,这是与问题最相关的部分。
【解决方案2】:

检查应用程序views.py 文件,return 语句中的render 或HttpResopose 函数有问题。我遇到了同样的错误,我的 return 语句中缺少渲染。

def relative(request): return render(request, 'basic_app/relative_url_templates.html')

【讨论】:

    猜你喜欢
    • 2020-11-07
    • 1970-01-01
    • 2020-04-21
    • 2019-05-23
    • 1970-01-01
    • 2015-06-22
    • 1970-01-01
    • 1970-01-01
    • 2019-10-04
    相关资源
    最近更新 更多