亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 SQLite3 找不到 Django 頁面

使用 SQLite3 找不到 Django 頁面

MMTTMM 2023-08-22 15:03:25
不知道為什么我會收到此錯誤,因為我的 ToDoList 中只有 1 個名為“Habibs List”的項目,但是當我轉到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>")我的網址配置:# 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"),]
查看完整描述

1 回答

?
哆啦的時光機

TA貢獻1779條經驗 獲得超6個贊

您只需將 url 路徑更改為path("<str:name>/", views.index, name="index")



查看完整回答
反對 回復 2023-08-22
  • 1 回答
  • 0 關注
  • 1605 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號