/ blog / index /'tuple'对象的AttributeError没有属性'get'

时间:2017-09-27 12:46:54

标签: python django

我是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的新应用程序,以及在博客中命名为templates的新目录,然后我在模板中构建了index.html。

index.html:

<h1>Hello blog</h1>

blog.views:

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

1 个答案:

答案 0 :(得分:2)

return删除尾随逗号。