urls.py
re_path(’^search_post$’, search.search_post),
post.html 文件代码:
{% csrf_token %}<p>{{ rlt }}</p>
search2.py 文件代码:
-- coding: utf-8 --
from django.shortcuts import render
from django.views.decorators import csrf
接收POST请求数据
def search_post(request):
ctx ={}
if request.POST:
ctx[‘rlt’] = request.POST[‘q’]
return render(request, “post.html”, ctx)