Python Development Learning-DAY16 (Django Framework First knowledge)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.