不知道為什么我會收到此錯誤,因為我的 ToDoList 中只有 1 個名為“Habibs List”的項目,但是當(dāng)我轉(zhuǎn)到http://127.0.0.1:8000/Habibs%20List時,它給了我這個錯誤:Page not found (404)Request Method: GETRequest URL: http://127.0.0.1:8000/Habibs%20ListUsing the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:admin/<int:id> [name='index']The current path, Habibs List, didn't match any of these.在我看來:def index(response, name): ls = ToDoList.objects.get(name=name) item = ls.item_set.get(id=1) return HttpResponse("<h1>%s</h1><br></br><p>%s</p>" % (ls.name, str(item.text)))# def v1(response):# return HttpResponse("<h1>Game Page</h1>")# def v2(response):# return HttpResponse("<h1>Electronic Page</h1>")我的網(wǎng)址配置:# the path to our different web pages# like the different views we have in our filefrom django.urls import pathfrom . import viewsurlpatterns = [ path("<int:id>", views.index, name="index"),]
添加回答
舉報
0/150
提交
取消