<form action="/jiexi_resume/" method="post" style="padding-left:100px">
本次优化唯一标识:<input id="random_str" type="text" name="random_str"> <br><br>
工作性质:  <label class="radio-inline">
<input type="radio" name="gzxz" value="zs" checked> 正式
</label>  
<label class="radio-inline">
<input type="radio" name="gzxz" value="wb"> 外包
</label>  
<label class="radio-inline">
<input type="radio" name="gzxz" value="jz"> 兼职
</label>
企业规模: <label class="radio-inline">
<input type="radio" name="qygm" value="xwqy" checked> 小微企业
</label>  
<label class="radio-inline">
<input type="radio" name="qygm" value="zxxgs"> 中小型公司
</label>  
<label class="radio-inline">
<input type="radio" name="qygm" value="dc"> 大厂
</label>
技术路线: <label class="radio-inline">
<input type="radio" name="jslx" value="python" checked> python
</label>  
<label class="radio-inline">
<input type="radio" name="jslx" value="java"> java
</label>  
<label class="radio-inline">
<input type="radio" name="jslx" value="none"> 无
</label>
<br><br>
<button type="submit" class="btn btn-outline-dark" style=";width:150px;">获取建议</button>
</form>
点击表单submit的获取建议,会触发 form action的请求。
后端处理代码
def jiexi_resume(request):
data = {}
for i in request.POST.lists():
print(i)
data[i[0]] = i[1][0]
print(data)
# datas = json.loads(i[0])
# print(datas['random_str'])
# HttpResponse('正在处理您的ID为:',datas['random_str'] )
return HttpResponse('正在处理您的ID为:'+ data['random_str'],content_type='text/plain;charset=utf-8')