だいぶご無沙汰になってしまってるコレ()
今週中に攫おう。。。
はじめに
【3日でできる】はじめての Django 入門 ( Python 3 でウェブアプリを作って AWS EC2 で公開!)レクチャー33で「http://127.0.0.1:8000/posts/1」に飛ぼうとすると
『"GET /posts/1 HTTP/1.1" 404 2392』というエラーが出る。
結論
1系と2系の違いは辛い
エラーを吐く書き方
path('posts/(?P<post_id>[0-9]+)/$' , views.post_detail ,name = "post_detail")
動作する書き方
path('posts/<int:post_id>' , views.post_detail ,name = "post_detail")
書き方がシンプルになってていいね!