Django path 路径参数和kwargs额外参数传递到视图层

Django path 路径参数和kwargs额外参数传递到视图层

url.py

from django.urls import path

from . import views

urlpatterns = [
    path("", views.index, name="index", kwargs = {"y":23}),
]

views.py

from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request,x, y):
    return HttpResponse("hello, world. You're at the polls index." + str(x) + str(y))

你可能感兴趣的:(python,后台)