python - tuple' 对象没有属性 'get'
问题描述
这是 django 为我提供的回溯。
if getattr(response, 'xframe_options_exempt', False):
return response
response['X-Frame-Options'] = self.get_xframe_options_value(request,response)
return response
def get_xframe_options_value(self, request, response):
获取要为 X_FRAME_OPTIONS 标头设置的值。使用 X_FRAME_OPTIONS 设置中的值,如果未设置,则使用“拒绝”。
如果需要,可以覆盖此方法,允许它根据请求或响应而变化。
return getattr(settings, 'X_FRAME_OPTIONS', 'DENY').upper()
我很难弄清楚为什么会发生这个错误。如何找出该元组在我的代码中的位置?这是一个应用程序的一个视图
from django.shortcuts import render
from django.http import HttpResponse
from .models import destination
# Create your views here.
def index(request):
dests=destination.objects.all()
return render(request,'index.html',{'dests':dests}),
现在这是第二个视图
from django.http import HttpResponse
from django.shortcuts import render
def HOMEE(request):
return render(request,'HOMEE.html'),
解决方案
推荐阅读
- javascript - CSS URL图像未覆盖视口
- python - txt 文件不会在 windows 中用 python 编写,它适用于 mac
- html - Angular - 从 GraphQL 返回数据
- ssh - 通过 ssh 执行时如何解析 echo 中的远程服务器名称
- java - 在 RelativeLayout 中使单个视图可见
- c# - 提供文件,下载完成后记录
- java - JavaFX:拖放操作导致冻结放置图标后弹出警报
- c++ - 与 C++11 `enum class` 的 ABI 兼容性保留
- reporting-services - SSRS 折线图 X 轴上的同一日期
- sql - 无法插入数据,postgresql 上的外键错误