1、模板语言中的for循环的最后一个的表示方式
{% for auther in auther_list %} {% if forloop.last %} {# 这里的意思是for循环的最后一个的意思#} <option value="{{ auther.id }}">{{ auther.auther_name }}</option> {% else %} <option value="{{ auther.id }}">{{ auther.auther_name }}</option>| {% endif %} {% endfor %}
2、如果使用bootstrap的表单太宽,可以在表单的标签放在下面的标签的里面
<div class="row"> <div class="col-md-5 col-md-offset-3"> </div> </div>
3、获取前台发过来的多选的数据
auther_list = request.POST.getlist("book_auther") # 如果页面是多选的select或者checkbox,则后台如果想获取前台传递过来的值,则使用getlist方法