I am trying to load my quote/customer page. I get the following error message.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/quote/customer
Django Version: 5.0.6
Python Version: 3.12.3
Installed Applications:
['web_data',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'quote']
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:\Python312\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\site-packages\django\utils\deprecation.py", line 136, in __call__
response = self.process_response(request, response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\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 /quote/customer
Exception Value: 'SafeString' object has no attribute 'get'
In the yellow background error message this stands out to me
AttributeError at /quote/customer
'SafeString' object has no attribute 'get'
Request Method: GET
Request URL: http://127.0.0.1:8000/quote/customer
Django Version: 5.0.6
Exception Type: AttributeError
Exception Value:
'SafeString' object has no attribute 'get'
Exception Location: C:\Python312\Lib\site-packages\django\middleware\clickjacking.py, line 27, in process_response
Raised during: quote.views.Contact_Information_Form
Python Executable: C:\Python312\python.exe
Python Version: 3.12.3
Based on this I see that my view Contact_Information_Form is showing an error. But where did I make a mistake?
views.py
from django.shortcuts import render
from django.http import HttpResponse
from django import forms as django_forms
from . import forms
# need to import views in the urls.py of quote
# Create your views here.
class Contact_Information_Form(django_forms.Form):
template_name = "customer.html"
form_class = forms.Customer_Form
# this method is called when a valid form data has been POSTed.
# def form_valid(self, form):
# form
# return super().form_valid(form)
#
my project level urls.py
# urls.py -> django_project url
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("quote/", include("quote.urls")),
]
My app level urls.py
# quote/urls.py -> app urls
from django.urls import path
from . import views
urlpatterns = [
path("customer", views.Contact_Information_Form),
]