Django error: 'tuple' object has no attribute 'get'

42 Views Asked by At

So, I started to make my first Django project, everything was okay but when I make my second site and Runserver this message popped up:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 4.2.3
Python Version: 3.10.6
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'home']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "C:\Users\hungp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
  File "C:\Users\hungp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\deprecation.py", line 136, in __call__
    response = self.process_response(request, response)
  File "C:\Users\hungp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\middleware\clickjacking.py", line 27, in process_response
    if response.get("X-Frame-Options") is not None:

Exception Type: AttributeError at /
Exception Value: 'tuple' object has no attribute 'get'

Here is my code: views.py:

from django.shortcuts import render

# Create your views here.
def home(request):
    return render(request, 'home/home.html'),
def product(request):
    return render(request, 'home/product.html'),
def register(request):
    return render(request, 'home/register.html'),

I have try looking in my views.py file, my urls.py and even setting.py but I couldn't find any tuple as mentioned in the error. I have also tried reinstalling Django but it didn't work. The last thing that I did was check my views.py as suggested on some previous error posts on StackOverflow but it didn't work either.

Edit 1: I found the solution. The error is in the comma at the end of the view code (You can see it at the end of each line, EX: return render(request, 'home/home.html')***,***). The solution to this error is to remove the comma and it should work.

0

There are 0 best solutions below