I have a app with m404 define. And, Django can’t except site errors. Can you help me? Just send here correct exception code.
from django.http import *
views.py:
from django.http import *
from django.shortcuts import render
return HttpResponseNotFound("<h2>Not Found</h2>")
def products(request, productid):
category = request.GET.get("cat", "")
name = request.GET.get("name", "")
output = "<h2>Product № {0} Category: {1}</h2>".format(productid, category)
return HttpResponse(output)
def users(request):
id = request.GET.get("id", 1)
name = request.GET.get("name", "Tom")
output = "<h2>User</h2><h3>id: {0} name: {1}</h3>".format(id, name)
return HttpResponse(output)
def about(request):
return HttpResponse("<h1>About</h1>")
def contact(request):
return HttpResponseRedirect("/about")
def index(request):
header = "Personal Data"
language = ["Russian", "English", "German"]
user = {"name": "Tom Bazucki", "category": "Django"}
addr = ("Апельсиновая", 23, 45)
data = {"header": header, "language": language, "user": user, "addr": addr}
return render(request, "index.html", context=data)
def slash(request):
return HttpResponseRedirect("/index")
urls.py:
from firstapp import views
urlpatterns = [
path("index/", views.index),
path('', views.slash),
path('products/<int:productid>', views.products),
path('users/', views.users),
path('contact/', views.contact),
path('about/', views.about)
]