首页 > 其他 > 详细

django一些之前没有用过的小点

时间:2018-09-11 10:49:08      阅读:173      评论:0      收藏:0      [点我收藏+]

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方法

  

django一些之前没有用过的小点

原文:https://www.cnblogs.com/bainianminguo/p/9625388.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!