課程
/后端開發(fā)
/Python
/三小時帶你入門Django框架 新版上架
^ play / ^ detail / <int:article_id> $
2019-12-20
源自:三小時帶你入門Django框架 新版上架 4-5
正在回答
django?3.1.5?這樣寫 path('detail/<int:article_id>/',?blog.views.get_detail),
參考https://docs.djangoproject.com/
應該是版本不一樣所以路由配置不一樣把,你改改這個試試:
就是把老師講的那個<int:article_id>改成
(?P<article_id>[0-9]+)
具體和上圖那樣子。
然后在views.py里面稍微改一下
只有第41行的代碼不一樣,注意改一下,然后應該就可以了
我也是這個錯誤
url(r'^detail/<int:article_id>$',views.get_detail_page) def?get_detail_page(request,article_id): ????all_article?=?Article.objects.all() ????curr_article?=?None ????for?article?in?all_article: ????????if?article.article_id?==?article_id: ????????????curr_article?=?article ????????????break ????#curr_article?=?Article.objects.all()[1] ????session_list?=?curr_article.content.split('\n') ????return?render(request,'cs/detail.html', ??????????????????{ ??????????????????????'curr_article':?curr_article, ??????????????????????'session_list':session_list ??????????????????})
Using the URLconf defined in?project.urls, Django tried these URL patterns, in this order:
project.urls
^play/ ^hello/$
^play/ ^content/$
^play/ ^index/$
^play/ ^detail/<int:article_id>$
^admin/
The current path,?play/detail/1, didn't match any of these.
play/detail/1
舉報
Python開發(fā)上手Web框架的必備課程,三小時帶你入門Django框架。
1 回答進入http://127.0.0.1:8000/blog/hello_world報錯
4 回答404找不到,一直都沒有解決。
2 回答前面的都沒問題,但是訪問127.0.0.1:8000顯示Not Found
1 回答一直報404 找了好久,不知道為啥
1 回答view.py中,index的路徑
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2021-02-01
2020-01-10
應該是版本不一樣所以路由配置不一樣把,你改改這個試試:

就是把老師講的那個<int:article_id>改成
具體和上圖那樣子。
然后在views.py里面稍微改一下
只有第41行的代碼不一樣,注意改一下,然后應該就可以了
2020-01-10
我也是這個錯誤
2019-12-20
2019-12-20
Page not found?(404)
Using the URLconf defined in?
project.urls
, Django tried these URL patterns, in this order:^play/ ^hello/$
^play/ ^content/$
^play/ ^index/$
^play/ ^detail/<int:article_id>$
^admin/
The current path,?
play/detail/1
, didn't match any of these.