1

I'm a beginner in python.I get an error and I have been struggling with for hours.

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

And this is traceback:

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'

This is a simple project ,I built a new app named blog ,and new directory named templates in blog ,then I built index.html in templates .

The index.html :

<h1>Hello blog</h1>

The blog.views :

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

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

The settings:

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

Charles
  • 13
  • 2

1 Answers1

2

Remove the trailing comma from your return.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895