S12-20160507-day16
Pytho Automation Development day16date:2016.05.07
@南非波波
Course Outline:
Http://www.cnblogs.com/alex3714/articles/5457672.html
First, Django start
1. Create a Django Project
两种方式:使用pycharm工具进行创建 使用manage命令进行创建
2.url Design
3.views View Design
4.Template Version Design
Ii. Template Rendering
1. Invoking the data passed by the backend
2. Traversing data with a for loop
<url> {% for user_info in user_obj %} <li style="">username:{{user_info.username}},E-mail:{{user_info.email}}</li> {% endfor %}</url>
3. Use if to determine the relevant conditions
<url> {% for user_info in user_obj %} {# {% if user_info.username == "swht" %}#} <!--可以直接判断某个字符串,然后进行处理--> {% if forloop.counter0|divisibleby:"2" %} <!--使用forloop。counter参数获取遍历的当前数字。counter0是从0开始的索引值,divisibleby:"2"是指能够被2整除--> <li style="background-color: aqua">username:{{user_info.username}},E-mail:{{user_info.email}}</li> {% else %} <li style="">username:{{user_info.username}},E-mail:{{user_info.email}}</li> {% endif %} {% endfor %}</url>
Python Development Learning-DAY16 (Django Framework First knowledge)