urlpatterns = [
path('<int:num>/', views.index, name='index'),
]
urlpatternsで割り当てられるviews.pyのindex関数を修正しましょう。下のリスト欄のように書き換えて下さい。そして修正できたら以下のようにアクセスをしてみましょう。
http://localhost:8000/hello/100
def index(request, num):
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
def index(request, num): total = num for i in range(num): total += i context = { 'msg': str(num) + ' までの合計は、 ' + str(total), } return render(request, 'hello/index.html', context)
<< 前へ | 次へ >> |