gpt4 book ai didi

python - AttributeError at/blog/index/'tuple' 对象没有属性 'get'

转载 作者:行者123 更新时间:2023-12-01 02:34:07 24 4
gpt4 key购买 nike

我是 python 的初学者。我遇到一个错误,并且已经苦苦挣扎了几个小时。

AttributeError at /blog/index/
'tuple' object has no attribute 'get'
Request Method: GET
Request URL: http://localhost:8000/blog/index/
Django Version: 1.10.2
Exception Type: AttributeError

Exception Value:
'tuple' object has no attribute 'get'

Exception Location:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/middleware/clickjacking.py in process_response, line 32

Python Executable:/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.13
<小时/>

这是回溯:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/deprecation.py" in __call__
135. response = self.process_response(request, response)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/middleware/clickjacking.py" in process_response
32. if response.get('X-Frame-Options') is not None:

Exception Type: AttributeError at /blog/index/
Exception Value: 'tuple' object has no attribute 'get'
<小时/>

这是一个简单的项目,我构建了一个名为 blog 的新应用程序,并在 blog 中创建了名为 templates 的新目录,然后在 templates 中构建了 index.html 。

index.html:

<h1>Hello blog</h1>

博客浏览量:

from django.shortcuts import render
from django.http import HttpResponse

def index(request):
return render(request,'index.html'),

设置:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog']

enter image description here

最佳答案

删除回车符中的尾随逗号。

关于python - AttributeError at/blog/index/'tuple' 对象没有属性 'get',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46448285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com