Hello one! This is Ponta, a Shiba Inu. When I was playing ball in the park today, I was very embarrassed to receive the ball on my face.
Now, as the title suggests, I would like to receive and display URL query parameters. http://example.com/wan/?type=shiba&name=Ponta If it is written, it will be received as data of {type: shiba}, {name: Ponta} (combination of {key: value}).
(venv_dog) Ponta@shiba_app # cat wan/views.py
from django.http import HttpResponse
def index(request):
if 'name' in request.GET:
name = request.GET['name']
res = "Name is" + name + "is."
else:
res = ""
if 'dogtype' in request.GET:
dogtype = request.GET['dogtype']
res = res + "The breed of dog" + dogtype + "is."
if len(res) == 0:
res = "Wan! name(name)And dog breed(dogtype)Please tell me!"
return HttpResponse(res)
(venv_dog) Ponta@shiba_app #
Did you do it well?
When there are parameters
When not
One that worked! See you dear! Bye bye!
Recommended Posts