继reverse反向路由,此次我们可以通过from django.shortcuts import redirect 与reverse配合实现路由跳转,具体如下:
views.py文中:
from django.shortcuts import redirect#新导入 # Create your views here. def index(request): print(reverse("index")) return redirect(reverse('find2',args=[15291917110,'冯瑞']))
增加redirect(reverse('find2',args=[15291917110,'冯瑞'])),即登陆localhost:8000/myapp/index后即可跳转至http://localhost:8000/myapp/find/15291917110/冯瑞页面。