
urlpatternsを修正する。
hello/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('<int:id>/<nickname>/', views.index, name='index'),
]
次にindex関数を修正する。
hello/views.py
from django.shortcuts import render
from django.http import HttpResponse
def index(request, id, nickname):
result = 'your id: ' + str(id) + ', name: "' \
+ nickname + '".'
return HttpResponse(result)
webブラウザにてアクセスする。

この記事は役に立ちましたか?
もし参考になりましたら、下記のボタンで教えてください。
コメント