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



我是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'

这是一个简单的项目,我构建了一个名为博客的新应用,而新的目录则在博客中,然后我在模板中构建了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']

在此处输入图像描述

从您的 return删除尾随逗号。

最新更新