django模板语言之for 循环 if else

                        {% for publish in pulish_list %}
                            {% if publish.id == book_obj.publisher_id %}
                                <option value="{{ publish.name }}" selected="selected">{{ publish.name }}</option>
                            {% else %}
                                <option value="{{ publish.name }}">{{ publish.name }}</option>
                            {% endif %}
                        {% endfor %}

 

posted @ 2017-12-10 16:47  hello沃德  阅读(1832)  评论(0)    收藏  举报