Django表单post请求

urls.py
re_path(’^search_post$’, search.search_post),

post.html 文件代码:

{% csrf_token %}

{ { rlt }}

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)

你可能感兴趣的:(Django)