0
点赞
收藏
分享

微信扫一扫

Python Django 4.2.5教程:url中带请求参数(question/detail/<int:question_id>/)

Ichjns 2023-10-18 阅读 13


vim django-20231002/mysite/polls/views.py

from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
    return HttpResponse('hello django polls index')

def q_detail(request,question_id):
    return HttpResponse('you are looking for %s.'%question_id)

vim django-20231002/mysite/polls/urls.py

from django.urls import path
from . import views

urlpatterns=[
    path('index/',views.index),
    path('question/detail/<int:question_id>/',views.q_detail),
]

演示

请求http://localhost:8000/polls/question/detail/1/

Python Django 4.2.5教程:url中带请求参数(question/detail/<int:question_id>/)_python

links:

https://www.w3cschool.cn/django4/django4-esfw3lyr.html


举报

相关推荐

0 条评论