获取单个值
request.POST.get('user') # user对应前端name属性对应的值
获取多个值(如checkbox,multiple)
request.POST.getlist('favor') # favor对应前端name属性对应的值
获取文件
# 表单需加enctype <form action="/login/" method="POST" enctype="multipart/form-data"> obj = request.FILES.get('imgs') f = open(obj.name, mode='wb') for i in obj.chunks(): f.write(i) f.close()
前端展示数据
# 循环获取字典的值 <ul> {% for k,v in dict.items %} <li> {{ k }} -{{ v }} </li> {% endfor % } </ul>