मैं अजगर में एक नौसिखिया हूँ। मुझे एक त्रुटि मिलती है और मैं घंटों तक संघर्ष कर रहा हूं।
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>
ब्लॉग। अवलोकन:
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"]
उत्तर:
जवाब के लिए 2 № 1अपने पीछे पीछे कॉमा हटा दें return
.