有没有办法从 Django 的请求中获取所有表单名称?
<input type="text" name="getrow">
html请求
def demoform(request):
if request.method=="POST"
inputtxt=request.POST.get("getrow")
return HttpResponse(...)
在上面我只能从name
我知道,我需要的是获取 django 请求的所有名称,然后解析它并获取数据。
尝试使用这个:
def demoform(request):
if request.method=="POST":
inputtxt=request.POST['getrow']
return HttpResponse(...)
但如果您需要打印动态 POST 数据,例如发送许多产品的 slug,(我是在 2 天前“2018 年 4 月 22 日”制作的),您需要尝试以下操作:
for key, value in request.POST.items():
print('Key: %s' % (key) )
# print(f'Key: {key}') in Python >= 3.7
print('Value %s' % (value) )
# print(f'Value: {value}') in Python >= 3.7
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)