以下內容據轉載自小鄭鄭要飛飛的專欄,僅用于學習和交流使用,如有侵權立即刪除。
模版的創建過程,對于模版,其實就是讀取模版(其中嵌套著模版標簽),然后將 Model 中獲取的數據插入到模版中,最后將信息返回給用戶。
注意:當數據POST的時候,Django做了跨站請求偽造。-
模版語言
{{ person_name }}
{{ ship_date|date:"F j, Y" }} 不建議{{ bio|truncatewords:"30" }}
{{ my_list|first|upper }}
{{ name|lower }}
{% for item in item_list %} <li>{{ item }}</li> {% endfor %}
forloop.counter0
forloop.revcounter
forloop.revcounter0
forloop.first
forloop.last
forloop.parentloop
{% if ordered_warranty %}
{% if not ordered_warranty %}
{% include 'includes/nav.html' %} 包含標簽
{% block title %}{% endblock %} {% extends "base.html" %} 模板
{# this is not a comment #} {% comment %}{% endcomment %}
{% ifequal user currentuser %} {% endifequal %}