Django模板语言和模板 整理

  • 傻萌新的templates

小白如我一开始是使用思路为return HttpResponse("hello world")的方式来返回到前端呈现的。

  • 思路点拨

看了大佬们的博客,明确了症结:这种方式把数据和视图混在一起,不符合Django的MTV思想。

  • 正常人的templates

<h1>{{ hello }}h1>


现在开始学习

首先放上我学习的博客:

https://blog.csdn.net/HuangZhang_123/article/details/70255545

https://www.cnblogs.com/6324TV/p/8672021.html

https://www.cnblogs.com/CongZhang/p/5944463.html

https://blog.csdn.net/inuyasha1121/article/details/43952073

需要记两种特殊符号:

{{  }}和 {% %}

变量相关的用{{ }},逻辑相关的用{% %}


 {%ttttt%}是模板标签,{{vvvv}}是模板变量,{{eee|jjj:...}}是过滤器形式


变量

{{ 变量名 }}

  1. 变量名由字母数字和下划线组成。
  2. 点(.)在模板语言中有特殊的含义,用来获取对象的相应属性值。

下面是使用(.)的例子:

views.py中的代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def  template_test(request):
     =  [ 11 22 33 ]
     =  { "name" "alex" }
 
     class  Person( object ):
         def  __init__( self , name, age):
             self .name  =  name
             self .age  =  age
 
         def  dream( self ):
             return  "{} is dream..." . format ( self .name)
 
     Alex  =  Person(name = "Alex" , age = 34 )
     Egon  =  Person(name = "Egon" , age = 9000 )
     Eva_J  =  Person(name = "Eva_J" , age = 18 )
 
     person_list  =  [Alex, Egon, Eva_J]
     return  render(request,  "template_test.html" , { "l" : l,  "d" : d,  "person_list" : person_list})

html模板中支持的写法:

1
2
3
4
5
6
7
8
{ # 取l中的第一个参数 #}
{{ l. 0  }}
{ # 取字典中key的值 #}
{{ d.name }}
{ # 取对象的name属性 #}
{{ person_list. 0.name  }}
{ # .操作只能调用不带参数的方法 #}
{{ person_list. 0.dream  }}

当templates引擎遇到变量时,引擎使用变量的值代替变量。使用(.)访问变量的属性,比如{{d.name}}。当templates引擎遇到(.)的时候,会按照如下顺序查找:

  1. 字典查找,例如:foo['bar']  
  2. 属性查找,例如:foo.bar  
  3. 方法查找,例如:foo.bar()  
  4. list-index查找,例如foo[bar]  


模板的大致结构(后面有详细)

Django的templates(templates:模板),它是一个string文本。templates用来分离一个文档的表现形式和内容(也可以说成数据)。templates定义了placeholder(placeholder:占位符)和表示多种逻辑的tags(tags:标签)来规定文档如何展现。通常templates用来输出HTML,但是Django的templates也能生成其他基于文本的形式。

模板大致结构:

<html>
<head><title>Ordering noticetitle>head>
<body>
<h1>Ordering noticeh1>
<p>Dear {{ person_name }},p>
<p>Thanks for placing an order from {{ company }}. It's scheduled to
ship on {{ ship_date|date:"F j, Y" }}.p>
<p>Here are the items you've ordered:p>
<ul>
{% for item in item_list %}
    <li>{{ item }}li>
{% endfor %}
ul>
{% if ordered_warranty %}
    <p>Your warranty information will be included in the packaging.p>
{% else %}
    <p>You didn't order a warranty, so you're on your own when
    the products inevitably stop working.p>
{% endif %}
<p>Sincerely,<br />{{ company }}p>
body>
html>

例子中,

用两个大括号括起来的文字(例如 {{ person_name }} )称为 变量(variable) 。这意味着在此处插入指定变量的值。

被大括号和百分号包围的文本(例如 {% if ordered_warranty %} )是 模板标签(template tag) 。标签(tag)定义比较明确,即: 仅通知模板系统完成某些工作的标签。

这个例子中的模板包含一个for标签( {% for item in item_list %} )和一个if 标签({% if ordered_warranty %} )

for标签类似Python的for语句,可让你循环访问序列里的每一个项目。 if 标签,正如你所料,是用来执行逻辑判断的。 在这里,tag标签检查ordered_warranty值是否为True。如果是,模板系统将显示{% if ordered_warranty %}和{% else %}之间的内容;否则将显示{% else %}和{% endif %}之间的内容。{% else %}是可选的。

就是通俗一点说, {{xxx}}这个为变量。{% %} 为语法使用。在整体上模版的结构就是如此。

至此了解到模版的大致结构。现在了解一下模版标签。


标签

(一)if/else标签

只能判断True 和False 
{% if %} 标签会考察一个变量,如果这个变量为真(即,变量存在,非空,不是布尔值假),系统会显示在 {% if %} 和 {% endif %} 之间的任何内容,例如:

{% if today_is_weekend %}
    <p>Welcome to the weekend!p>
{% endif %}

{% else %} 标签是可选的:

{% if today_is_weekend %}
    <p>Welcome to the weekend!p>
{% else %}
    <p>Get back to work.p>
{% endif %}

{% if %} 标签接受 and , or 或者 not 关键字来对多个变量做判断 ,或者对变量取反( not ),但不允许在同一个标签中同时使用 and 和 or ,因为逻辑上可能模糊的。

(二)for标签

for标签用于迭代序列中的各个元素。 

与 Python 的 for 语句类似,语法是for X in Y。其中 Y 是要迭代的序列, X 是单次循环中使用的变量。每次迭代时,模板系统会渲染 {% for %} 和 {% endfor %} 之间的内容。

1.正向迭代

    {% for athlete in athlete_list %}
  • {{ athlete.name }}
  • {% endfor %}

2.加入reversed标签,反向迭代

{% for athlete in athlete_list reversed %} 
… 
{% endfor %}

3.对二元组解包

{% for x, y in points %}
    

There is a point at {{ x }},{{ y }}

{% endfor %}

4.字典解包

{% for key, value in data.items %}
    {{ key }}: {{ value }}
{% endfor %}

5.判断列表是否为空

在执行循环之前先检测列表的大小是一个通常的做法,当列表为空时输出一些特别的提示。

{% if athlete_list %}
    {% for athlete in athlete_list %}
        

{{ athlete.name }}

{% endfor %} {% else %}

There are no athletes. Only computer programmers.

{% endif %}

因为这种做法十分常见,所以for 标签支持一个可选的{% empty %} 分句,通过它,我们可以定义当列表为空时的输出内容。

{% for athlete in athlete_list %}
    

{{ athlete.name }}

{% empty %}

There are no athletes. Only computer programmers.

{% endfor %}

6. for标签内部模板变量forloop

在每个{% for %}循环里有一个称为forloop 的模板变量。 

  • forloop.counter 总是一个表示当前循环的执行次数的整数计数器。这个计数器是从1开始的,所以在第一次循环时 forloop.counter 将会被设置为1。 
{% for item in todo_list %}

{{ forloop.counter }}: {{ item }}

{% endfor %}
  • forloop.counter0 类似于 forloop.counter ,但是它是从0计数的。 第一次执行循环时这个变量会被设置为0。
  • forloop.revcounter的值是一个整数,表示循环中剩余的元素数量。第一次循环时, forloop.revcounter 的值是序列中要遍历的元素总数。最后一次循环时, forloop.revcounter的值为 1 。
  • forloop.revcounter0 与 forloop.revcounter类似,不过索引是基于零的。第一次循环时, forloop.revcounter0的值是序列中元素数量减去一。最后一次循环时, forloop.revcounter0 的值为 0 。
  • forloop.first 是个布尔值,第一次循环时为 True 。需要特殊处理第一个元素时很方便。
{% for object in objects %}
    {% if forloop.first %}
        
  • {% else %}
  • {% endif %} {{ object }}
  • {% endfor %}

    • forloop.last是个布尔值,最后一次循环时为True 。经常用它在一组链接之间放置管道符号(|)。
    {% for link in links %}
        {{ link }}{% if not forloop.last %} | {% endif %}
    {% endfor %}

    此外,还经常用它在一组单词之间放置逗号(,): 

    Favorite places:

    {% for p in places %} {{ p }}{% if not forloop.last %}, {% endif %} {% endfor %}
    • forloop.parentloop 是一个指向当前循环的上一级循环的 forloop 对象的引用(在嵌套循环的情况下)。
    {% for country in countries %}
        
        {% for city in country.city_list %}
            
        {% endfor %}
        
    Country #{{ forloop.parentloop.counter }} City #{{ forloop.counter }} {{ city }}
    {% endfor %}

    需要注意的是,

    forloop 变量只在循环内部可用。模板解析器遇到 {% endfor %} 时, forloop 随之消失。 

    如果有名为 forloop 的模板变量(不建议这么做),在 {% for %} 块中会重命名为 forloop.parentloop 。

    ifchanged
              使用形式:
              (a)如果直接检测循环变量是否变化,那么使用:
                  {% ifchanged %}  
                      (内容)
                  {% endifchanged %}
              (b)如果检测循环变量的某个dot变量,例如循环变量是date,那么检测date.hour,那么使用:
                  {% ifchanged date.hour%}  
                      (内容)
                  {% endifchanged %}    
              (c)ifchanged也可以加上一个{% else %}语句
              意义:检测本次循环的值和上一次循环的值一样不一样,只能用在循环里面。

    (三)ifequal / ifnotequal 标签

    对比两个值是否相对,ifequal相等,ifnotequal不相等。

    只有模板变量,字符串,整数和小数可以作为 {% ifequal %} 标签的参数。其他任何类型,例如Python的字典类型、列表类型、布尔类型,不能用在 {% ifequal %} 中。 

    下面的例子比较两个模板变量 user 和 currentuser :

    {% ifequal user currentuser %}
        

    Welcome!

    {% endifequal %}

    参数可以是硬编码的字符串,随便用单引号或者双引号引起来,所以下列代码都是正确的:

    {% ifequal section 'sitenews' %}
        

    Site News

    {% endifequal %}

    和 {% if %} 类似, {% ifequal %} 支持可选的 {% else%} 标签

    (四)一些常用标签

    (1)autoescape

    使用形式: 
    {% autoescape off %} 
    (内容) 
    {% endautoescape %} 
    意义:当某块内容不需要自动转义的时候,这样写就可以了。当然如果块内某些地方需要转义的话,调用filter也可以。

    (2)block

    使用形式: 
    {% block %} 
    (定义块内容) 
    {% endblock %} 
    意义:定义一个块,该块能够被继承他的子孙模板重写

    (3)comment

    使用形式: 
    {% comment %} 
    (内容) 
    {% endcomment %} 
    意义:模板系统会忽略该标签内部的所有内容。

    (4)cycle

    使用形式: 
    例如: 
    <\tr class=”{% cycle list%}”> 
    … 
    <\/tr> 
    意义:在循环时轮流使用给定的字符串列表中的值。

    (5)extends

    使用形式:{% extends “base.html” %}或者{% extends variable %}变量可以是一个字符串,也可以是一个模板对象。 
    意义:表示本模板要对指定的父模板进行扩展。

    (6)filter

    使用形式: 
    {%filter force_escape|lower%} 
    (内容) 
    {%endfilter%} 
    意义:将filter 标签圈定的内容执行过滤器操作。

    (7)firstof

    使用形式:{%firstof var1 var2 var3%} 
    意义:输出第一个值不等于False的变量 
    等价于: 
    {% if var1 %} 
    {{ var1 }} 
    {% else %} 
    {% if var2 %} 
    {{ var2 }} 
    {% else %} 
    {% if var3 %} 
    {{ var3 }} 
    {% endif %} 
    {% endif %} 
    {% endif %}

    (8)for

    使用形式: 
    {% for variable in list/dict %} 
    (使用variable) 
    {% endfor%} 
    意义:循环list中的每个值,进行相应的输出 
    注意:(a)也可以反向遍历{% for variable in list/dict reversed %} 
    (b)也可以{% for x, y in points %} points中的每个元素为 (x,y) 
    (c)也可以{% for key,value in data.items %} data是一个dictionary 
    for loop中定义的一些内建变量 
    forloop.counter 当前的迭代器数目(从1开始) 
    forloop.counter0 当前的迭代器数目(从0开始) 
    forloop.revcounter 当前的反向迭代器数目(从1开始) 
    forloop.revcounter0 当前的反向迭代器数目(从0开始) 
    forloop.first 值为True,如果是第一次通过迭代器 
    forloop.last 值为True,如果是最后一次通过迭代器 
    forloop.parentloop 对于嵌套循环,这是当前循环的上一层循环

    (9)for … empty

    使用形式如下: 
    {% for varibale in list %} 
    (内容1) 
    {% empty %} 
    (内容2) 
    {% endfor %} 
    意义:当list是空的时候,能够执行内容2,其形式等同于,先if判断list是否存在,然后在根据情况做什么操作。

    (10)if

    使用形式如下 : 
    {% if variable %} 
    (内容1) 
    {% else %} 
    (内容2) 
    {% endif %} 
    注意:variable中可以使用and or 或者not,但是有一条必须记住,就是不允许and 和 or一起使用

    (11)ifchanged

    使用形式: 
    (a)如果直接检测循环变量是否变化,那么使用: 
    {% ifchanged %} 
    (内容) 
    {% endifchanged %} 
    (b)如果检测循环变量的某个dot变量,例如循环变量是date,那么检测date.hour,那么使用: 
    {% ifchanged date.hour%} 
    (内容) 
    {% endifchanged %} 
    (c)ifchanged也可以加上一个{% else %}语句 
    意义:检测本次循环的值和上一次循环的值一样不一样,只能用在循环里面。

    (12)ifequal

    使用形式: 
    {% ifequal variable1 variable2 %} 
    … 
    {% endifequal %} 
    意义:判断两个变量是否相等。

    (13)ifnotequal

    使用与(12)相同

    (14)include

    使用形式:{% include “foo/bar.html” %}或者{% include template_name %} 
    意义:将另外一个模板文件中的内容添加到该文件中。注意区别extend是继承。

    (15)now

    使用形式:{% now “jS F Y H:i “%},注意存在需要转义的情况例如{% now “jS o\f F” %},因为f是格式化字符串

    具体的格式化字符串如下所示

    a ‘a.m.’ or ‘p.m.’ (Note that this is slightly different than PHP’s output, because this includes periods to match Associated Press style.) ‘a.m.’ 
    A ‘AM’ or ‘PM’. ‘AM’ 
    b Month, textual, 3 letters, lowercase. ‘jan’ 
    B Not implemented. 
    d Day of the month, 2 digits with leading zeros. ‘01’ to ‘31’ 
    D Day of the week, textual, 3 letters. ‘Fri’ 
    f Time, in 12-hour hours and minutes, with minutes left off if they’re zero. Proprietary extension. ‘1’, ‘1:30’ 
    F Month, textual, long. ‘January’ 
    g Hour, 12-hour format without leading zeros. ‘1’ to ‘12’ 
    G Hour, 24-hour format without leading zeros. ‘0’ to ‘23’ 
    h Hour, 12-hour format. ‘01’ to ‘12’ 
    H Hour, 24-hour format. ‘00’ to ‘23’ 
    i Minutes. ‘00’ to ‘59’ 
    I Not implemented. 
    j Day of the month without leading zeros. ‘1’ to ‘31’ 
    l Day of the week, textual, long. ‘Friday’ 
    L Boolean for whether it’s a leap year. True or False 
    m Month, 2 digits with leading zeros. ‘01’ to ‘12’ 
    M Month, textual, 3 letters. ‘Jan’ 
    n Month without leading zeros. ‘1’ to ‘12’ 
    N Month abbreviation in Associated Press style. Proprietary extension. ‘Jan.’, ‘Feb.’, ‘March’, ‘May’ 
    O Difference to Greenwich time in hours. ‘+0200’ 
    P Time, in 12-hour hours, minutes and ‘a.m.’/’p.m.’, with minutes left off if they’re zero and the special-case strings ‘midnight’ and ‘noon’ if appropriate. Proprietary extension. ‘1 a.m.’, ‘1:30 p.m.’, ‘midnight’, ‘noon’, ‘12:30 p.m.’ 
    r RFC 2822 formatted date. ‘Thu, 21 Dec 2000 16:01:07 +0200’ 
    s Seconds, 2 digits with leading zeros. ‘00’ to ‘59’ 
    S English ordinal suffix for day of the month, 2 characters. ‘st’, ‘nd’, ‘rd’ or ‘th’ 
    t Number of days in the given month. 28 to 31 
    T Time zone of this machine. ‘EST’, ‘MDT’ 
    U Not implemented. 
    w Day of the week, digits without leading zeros. ‘0’ (Sunday) to ‘6’ (Saturday) 
    W ISO-8601 week number of year, with weeks starting on Monday. 1, 53 
    y Year, 2 digits. ‘99’ 
    Y Year, 4 digits. ‘1999’ 
    z Day of the year. 0 to 365 
    Z Time zone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.

    (16)spaceless

    使用形式:{% spaceless %} 
    (内容) 
    {% endspaceless %} 
    意义:删除包围内容中的所有tab或者回车字符。

    (17)template

    使用形式:{% templatetag %} 
    意义:模板系统本身没有转义的概念,因此如果要输出一个像“{%”这样的东东,就需要采用这种方式,否则就会语法错误 
    其参数有:

    openblock {% 
    closeblock %} 
    openvariable {{ 
    closevariable }} 
    openbrace { 
    closebrace } 
    opencomment {# 
    closecomment #}

    (18)with

    使用形式: 
    {% with “expensive var1” as var2 %} 
    {% endwith %} 
    意义:当一个变量的访问消耗很大的模板解析时,可以用另外一个变量替换它,这种替换只有在with内部有效。

    (19)url

    使用形式:{% url path.to.some_view arg1,arg2 %} 
    意义:给定某个module中函数的名字,给定参数,那么模板引擎给你一个URL,从而避免硬编码URL到代码中

    注意:前提是URLconf中存在相应的映射,如果URLconf中没有该映射,那么会抛出异常, 
    这是可以选择使用 
    {% url path.to.view arg1 ,arg2 as the_url %} 
    <\a href=”{{ the_url }}”>Link to optional stuff \<\/\a> 
    其实这相当于 
    {% url path.to.view as the_url %} 
    {% if the_url %} 
    Link to optional stuff  
    {% endif %}

    csrf_token

    这个标签用于跨站请求伪造保护。

    在页面的form表单里面写上{% csrf_token %}


    过滤器

    通过过滤器可以改变变量的显示方式,过滤器的形式是:{{ variable | filter }},管道符号'|'代表使用过滤器。

    例如:

    {{value|default:"nohting"}}

    表示当value为空或None时就会显示”nothing“。

    Django中有几十个内建的过滤器。

    先看过滤器的使用说明:

    1.过滤器能够采用链式的方式使用

    例如:

    {{ text | escape | linebreaks }}

    2.过滤器可以带参数

    例如:

    {{ bio|truncatewords:30 }}

    如果参数中带有空格,那么需要用引号引起来,例如:

    {{ list | join : ", "}}

    下面是常用的Django内建过滤器:

    (1)add

    例如:

    {{ value | add: "2"}}

    意义:把value的值增加2。比如,value的值是4,那么输出为6。注意,add首先尝试把两个值当作整数相加,如果失败,就尝试把两个值组合在一起(比如遇到字符串或list的时候),其他失败的情况返回一个空字符串。

    例如:

    {{first|add:second}},first=[1,2,3],second=[4,5,6]

    输出结果为[1,2,3,4,5,6]。(小白我一开始以为是[5,7,9]。。。。。)

    (2)addslashes

    {{ value | addslashes }} 

    意义:在value中引号(单引号和双引号)前增加反斜线

    例如:

    {{value|addslashes}},value=I'm using Django

    输出结果为I\'m using Django

    (3)capfirst

    {{ value | capfirst }} 

    意义:value的第一个字符转化成大写形式

    (4)cut

    {{ value | cut:arg}} 

    意义:移出value中包含arg的字符串。如果value是"String with spaces",arg是" ",那么输出结果是"Stringwithspaces"

    (5)date

    意义:将日期格式数据按照给定的格式输出。

    {{ value | date:"D d M Y" }}

    如果value是一个datetime对象,那么输出将是字符串"Wed 09 Jan 2008"。

    下面的例子没有格式化字符串,这时候格式化字符串会自动采用DATE_FORMAT所设置的形式。

     {{ value | date }}

    (6)default

    意义:如果value的意义是False,那么输出使用缺省值。

    {{ value | default: "nothing" }}

    如果value是"",输出将是"nothing"。

    (7)default_if_none

    {{ value | default_if_none:"nothing" }}

    意义:如果value是None,那么输出将使用缺省值(这里是"nothing")

    (8)dictsort

    {{ value | dictsort:"name"}}

    意义:如果value的值是一个字典,那么返回值是按照关键字排序的结果。

    例如,如果value是 [ {'name': 'zed', 'age': 19}, {'name': 'amy', 'age': 22}, {'name': 'joe', 'age': 31}, ] 那么,输出是: [ {'name': 'amy', 'age': 22}, {'name': 'joe', 'age': 31}, {'name': 'zed', 'age': 19}, ]

    (9)dictsortreversed

    意义:如果value的值是一个字典,那么返回值是按照关键字排序的结果的反序。

    使用形式与上述(8)完全相同。

    (10)divisibleby

    {{ value | divisibleby:arg}}

    意义:如果value能够被arg整除,那么返回值将是True

    例如value是21,arg是3,那么输出将是True

    (11)escape

    {{ value | escape}} 

    意义:替换value中的某些字符,以适应HTML格式,包括:

    < 会被转换为 <

    > 会被转换位 >

    '(单引号)会被转换为 '

    " (双引号)会被转换为 "

    & 会被转换为 &

    注意:escape仅仅在输出的时候才起作用,所以escape不能够用在链式过滤器的中间,它总是最后一个过滤器。如果想在链式过滤器的中间使用,那么可以使用force_escape。

    (12)escapejs

    {{ value | escapejs }}

    意义:替换value中的某些字符,以适应JavaScript和Json格式

    (13)filesizeformat

    {{ value | filesizeformat }}

    意义:格式化value,使其成为易读的文件大小

    (14)first

    {{ value | first }}

    意义:返回列表中的第一个Item

    如果value是列表['a','b','c'],那么输出将是'a'

    (15)floatformat

    {{ value | floatformat}}或者{{value|floatformat:arg}}

    arg可以是正数,也可以是负数。没有参数的floatformat相当于floatformat:-1

    • 如果不带arg,那么引擎会四舍五入,同时最多只保留一位小数

    1. 34.23234    {{ value|floatformat }}  34.2  
    2. 34.00000    {{ value|floatformat }} 34  
    3. 34.26000    {{ value|floatformat }} 34.3  
    • 如果arg是正数,那么引擎会四舍五入,同时保留arg个位的小数

    1. 34.23234    {{ value|floatformat:3 }}   34.232  
    2. 34.00000    {{ value|floatformat:3 }}   34.000  
    3. 34.26000    {{ value|floatformat:3 }}   34.260 
    • 如果arg是负数,那么引擎会四舍五入,如果有小数部分,那么保留arg个位的小数,否则没有任何小数部分

    1. 34.23234    {{ value|floatformat:"-3" }}    34.232  
    2. 34.00000    {{ value|floatformat:"-3" }}    34  
    3. 34.26000    {{ value|floatformat:"-3" }}    34.26  


    (16)get_digit 

    使用形式:{{ value | get_digit:"arg"}}

    例如,如果value是123456789,arg是2,那么输出是8 

    意义:给定一个数字,返回,请求的数字,记住:1代表最右边的数字,如果value不是合法输入,那么会返回所有原有值。



    (17)iriencode 

    使用形式:{{value | iriencode}} 

    意义:如果value中有非ASCII字符,那么将其进行转化成URL中适合的编码,如果value已经进行过URLENCODE,该操作就不会再起作用。



    (18)join 

    使用形式:{{ value | join:"arg"}}

    如果value是['a','b','c'],arg是'//'

    那么输出是a//b//c 

    意义:使用指定的字符串连接一个list,作用如同python的str.join(list)



    19. last 

    使用形式:{{ value | last }} 

    意义:返回列表中的最后一个Item



    20. length 

    使用形式:{{ value | length }} 

    意义:返回value的长度。


    21. length_is 

    使用形式:{{ value | length_is:"arg"}} 

    意义:返回True,如果value的长度等于arg的时候

    例如:如果value是['a','b','c'],arg是3,那么返回True



    22. linebreaks 

    使用形式:{{value|linebreaks}} 

    意义:value中的"\n"将被替代,并且整个value使用

    (注意这里是个换行!!!!)包围起来,从而适和HTML的格式

    23. linebreaksbr

     使用形式:{{value |linebreaksbr}} 

    意义:value中的"\n"将被
    替代



    24. linenumbers 

    使用形式:{{value | linenumbers}} 

    意义:显示的文本,带有行数。



    25. ljust

     使用形式:{{value | ljust}} 

    意义:在一个给定宽度的字段中,左对齐显示value



    26. center

     使用形式:{{value | center}}

     意义:在一个给定宽度的字段中,中心对齐显示value



    27. rjust 

    使用形式:{{value | rjust}} 

    意义:在一个给定宽度的字段中,右对齐显示value



    28. lower 

    使用形式:{{value | lower}} 

    意义:将一个字符串转换成小写形式



    29. make_list 

    使用形式:{{value | make_list}} 

    意义:将value转换成一个list,对于字符串,转换成字符list;对于整数,转换成整数list 

    例如value是Joel,那么输出将是[u'J',u'o',u'e',u'l'];value是123,那么输出将是[1,2,3]



    30. pluralize 

    使用形式:{{value | pluralize}},或者{{value | pluralize:"es"}},或者{{value | pluralize:"y,ies"}} 

    意义:如果value不是1,则返回一个复数后缀,缺省的后缀是's'



    31. random 

    使用形式:{{value | random}} 

    意义:从给定的list中返回一个任意的Item



    32. removetags 

    使用形式:{{value | removetags:"tag1 tag2 tag3..."}} 

    意义:删除value中tag1,tag2....的标签。

    例如,如果value是

                    Joel a slug 

                    tags是"b span",

    那么输出将是:Joel a slug



    33. safe

     使用形式:{{value | safe}} 

    意义:当系统设置autoescaping打开的时候,该过滤器使得输出不进行escape转换



    34. safeseq 

    与上述safe基本相同,但有一点不同的就是:safe是针对字符串,而safeseq是针对多个字符串组成的sequence


    35. slice

     使用形式:{{some_list | slice:":2"}} 

    意义:与python语法中的slice相同,:2表示第一的第二个元素



    36. slugify 

    使用形式:{{value | slugify}} 

    意义:将value转换成小写形式,同事删除所有分单词字符,并将空格变成横线 

    例如:如果value是Joel is a slug,那么输出将是joel-is-a-slug



    37. stringformat 

    这个不经常用,先不说 

    简单举个例子:如果value是 10,那么输出 1.000000E+01



    38. striptags 

    使用形式:{{value | striptags}} 

    意义:删除value中的所有HTML标签



    39. time 

    使用形式:{{value | time:"H:i"}}或者{{value | time}} 

    意义:格式化时间输出,如果time后面没有格式化参数,那么输出按照TIME_FORMAT中设置的进行。



    40. title 

    转换一个字符串成为title格式。 如: value是 "my first post",输出: "My First Post"



    41. truncatewords 

    使用形式:{{value | truncatewords:2}} 

    意义:将value切成truncatewords指定的单词数目 

    例如,如果value是Joel is a slug 那么输出将是:Joel is ...



    42. truncatewords_html 

    使用形式同(39) 

    意义:truncation点之前如果某个标签打开了,但是没有关闭,那么在truncation点会立即关闭。 因为这个操作的效率比truncatewords低,所有只有在value是html格式时,才考虑使用。



    43. upper 

    转换一个字符串为大写形式



    44. urlencode 

    将一个字符串进行URLEncode



    45. urlize 

    意义:将一个字符串中的URL转化成可点击的形式。 

    使用形式:{{ value | urlize }} 

    例如,如果value是Check out www.djangoproject.com,那么输出将是: Check out www.djangoproject.com



    46. urlizetrunc 

    使用形式:{{ value | urlizetrunc:15}} 

    意义:与(43)相同,但是有一点不同就是现实的链接字符会被truncate成特定的长度,后面以...现实。



    47. wordcount

     返回字符串中单词的数目



    48. wordwrap 

    使用形式:{{value | wordwrap:5}} 

    意义:按照指定的长度包装字符串 

    例如,如果value是Joel is a slug,那么输出将会是: Joel is a slug



    49. timesince 

    使用形式:{{value | timesince:arg}} 

    意义:返回参数arg到value的天数和小时数 

    例如,如果 blog_date 是一个日期实例,表示 2006-06-01 午夜, 而 comment_date 是一个日期实例,表示 2006-06-01 早上8点, 那么 {{ comment_date|timesince:blog_date }} 将返回 "8 hours".



    50. timeuntil 

    使用形式:{{value | timeuntil}} 

    意义:与(47)基本相同,一个不同点就是,返回的是value距离当前日期的天数和小时数。


    注释写法

    1
    { # ... #}


    Django 模板概念和运用

    母板

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    = "en" >
       = "UTF-8" >
       - equiv = "x-ua-compatible"  content = "IE=edge" >
       = "viewport"  content = "width=device-width, initial-scale=1" >
       Title<</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">title></code> </div> <div class="line number8 index7 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python spaces" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;">  </code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">block page</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">-</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">css </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number9 index8 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python spaces" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;">  </code>  </div> <div class="line number10 index9 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python spaces" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;">  </code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">endblock </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number11 index10 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">head></code> </div> <div class="line number12 index11 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><body></code> </div> <div class="line number13 index12 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;">   </div> <div class="line number14 index13 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><h1>这是母板的标题<</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">h1></code> </div> <div class="line number15 index14 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;">   </div> <div class="line number16 index15 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">block page</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">-</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">main </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number17 index16 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;">   </div> <div class="line number18 index17 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">endblock </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number19 index18 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><h1>母板底部内容<</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">h1></code> </div> <div class="line number20 index19 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">block page</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">-</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">js </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number21 index20 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;">   </div> <div class="line number22 index21 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">endblock </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number23 index22 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">body></code> </div> <div class="line number24 index23 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">html></code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);">  </p> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">注意:我们通常会在母板中定义页面专用的CSS块和JS块,方便子页面替换。</span></p> <h2 style="margin-top:20px;margin-bottom:20px;padding:0px;line-height:1.5;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:18px;">继承母板</span></h2> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">在子页面中在页面最上方使用下面的语法来继承母板。</span></p> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="padding:0px;width:806px;margin:1em 0px;font-size:1em;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">extends </code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">'layouts.html'</code>  <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <h2 style="margin-top:20px;margin-bottom:20px;padding:0px;line-height:1.5;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:18px;">块(block)</span></h2> <p style="margin:10px auto;"><span style="font-size:16px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);">通过在母板中使用{%block xxx%}</span><span><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:16px;color:#333333;"><span style="background-color:rgb(255,255,255);">来定义"块"。</span></span></span></p> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">在子页面中通过定义母板中的block名来对应替换母板中相应的内容。</span></p> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="padding:0px;width:806px;margin:1em 0px;font-size:1em;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 2 </div> <div class="line number3 index2 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 3 </div> <div class="line number4 index3 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 4 </div> <div class="line number5 index4 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 5 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">block page</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">-</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">main </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python spaces" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;">  </code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><p>世情薄<</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">p></code> </div> <div class="line number3 index2 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python spaces" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;">  </code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><p>人情恶<</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">p></code> </div> <div class="line number4 index3 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python spaces" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;">  </code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><p>雨送黄昏花易落<</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">p></code> </div> <div class="line number5 index4 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">endblock </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <h2 style="margin-top:20px;margin-bottom:20px;padding:0px;line-height:1.5;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:18px;">组件</span></h2> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">可以将常用的页面内容如导航条,页尾信息等组件保存在单独的文件中,然后在需要使用的地方按如下语法导入即可。</span></p> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="padding:0px;width:806px;margin:1em 0px;font-size:1em;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">include </code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">'navbar.html'</code>  <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <h2 style="margin-top:20px;margin-bottom:20px;padding:0px;line-height:1.5;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:18px;">静态文件相关</span></h2> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="padding:0px;width:806px;margin:1em 0px;font-size:1em;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 2 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">load static </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><img src</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"{% static "</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">images</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">hi.jpg</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">" %}"</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">alt</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"Hi!"</code>  <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">></code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">引用JS文件时使用:</span></p> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="padding:0px;width:806px;margin:1em 0px;font-size:1em;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 2 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">load static </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><script src</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"{% static "</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">mytest.js</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">" %}"</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">><</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">script></code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">某个文件多处被用到可以存为一个变量</span></p> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="padding:0px;width:806px;margin:1em 0px;font-size:1em;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 2 </div> <div class="line number3 index2 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 3 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">load static </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">static </code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"images/hi.jpg"</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">as myphoto </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number3 index2 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><img src</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"{{ myphoto }}"</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">><</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">img></code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">使用get_static_prefix</span></p> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="padding:0px;width:806px;margin:1em 0px;font-size:1em;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 2 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">load static </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><img src</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"{% get_static_prefix %}images/hi.jpg"</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">alt</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"Hi!"</code>  <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">></code> </div> </div></td> </tr> </tbody> </table> </div> </div> </div> <p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:16px;">或者</span></p> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"> <div class="syntaxhighlighter python" style="font-size:1em;padding:0px;width:806px;margin:1em 0px;"> <table border="0" style="border-spacing:0px;max-width:850px;border:1px solid #C0C0C0;width:806px;margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <tbody style="margin:0px;padding:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <tr style="margin:0px;padding:0px;background:none;border-top:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <td class="gutter" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:35px;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;color:rgb(175,175,175);"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 1 </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 2 </div> <div class="line number3 index2 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 3 </div> <div class="line number4 index3 alt1" style="margin:0px;padding:0px .5em;background-image:none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 4 </div> <div class="line number5 index4 alt2" style="margin:0px;padding:0px .5em;background:rgb(244,244,244) none;border-width:0px 2px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;height:auto;line-height:1.8em;text-align:right;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> 5 </div></td> <td class="code" style="padding:3px;border-color:#C0C0C0;border-collapse:collapse;margin:0px;background:none;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:12px;min-height:auto;"> <div class="container" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.1em;vertical-align:baseline;width:auto;min-height:auto;"> <div class="line number1 index0 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">load static </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number2 index1 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">{</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">get_static_prefix as STATIC_PREFIX </code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">%</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">}</code> </div> <div class="line number3 index2 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;">   </div> <div class="line number4 index3 alt1" style="margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><img src</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"{{ STATIC_PREFIX }}images/hi.jpg"</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">alt</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"Hi!"</code>  <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">></code> </div> <div class="line number5 index4 alt2" style="margin:0px;padding:0px 1em;background:rgb(244,244,244) none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;min-height:auto;white-space:nowrap;"> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);"><img src</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"{{ STATIC_PREFIX }}images/hi2.jpg"</code>  <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">alt</code> <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">=</code> <code class="python string" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:#0000FF;">"Hello!"</code>  <code class="python keyword" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,255);">/</code> <code class="python plain" style="margin:0px;padding:0px;background:none;border:0px;float:none;height:auto;line-height:1.8em;vertical-align:baseline;width:auto;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;white-space:nowrap;color:rgb(0,0,0);">></code> </div> </div></td> </tr> </tbody> </table> <br> </div> </div> </div> <div class="cnblogs_Highlighter sh-gutter" style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> <div style="margin:0px;padding:0px;"></div> </div> <h3 style="margin-top:10px;margin-bottom:10px;padding:0px;line-height:1.5;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"><span style="font-size:18px;"><span style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">include 模板标签</span><span style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"> </span></span></h3> <p></p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">内建模板标签:该标签允许在(模板中)包含其它的模板的内容。就是html里面的iframe <br>下面这两个例子都包含了 nav.html 模板。这两个例子是等价的,它们证明单/双引号都是允许的。</p> <pre class="prettyprint" style="font-size:14px;line-height:22px;"><code class="hljs ruby has-numbering">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">include</span> <span class="hljs-string" style="margin:0px;padding:0px;">'nav.html'</span> %} {% <span class="hljs-keyword" style="margin:0px;padding:0px;">include</span> <span class="hljs-string" style="margin:0px;padding:0px;">"nav.html"</span> %}</code></pre> <ul class="pre-numbering"> <li style="color:rgb(153,153,153);">1</li> <li style="color:rgb(153,153,153);">2</li> </ul> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">下面的例子包含了 includes/nav.html 模板的内容:</p> <pre class="prettyprint" style="font-size:14px;line-height:22px;"><code class="hljs ruby has-numbering">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">include</span> <span class="hljs-string" style="margin:0px;padding:0px;">'includes/nav.html'</span> %}</code></pre> <ul class="pre-numbering"> <li style="color:rgb(153,153,153);">1</li> </ul> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">下面的例子包含了以变量 template_name 的值为名称的模板内容:</p> <pre class="prettyprint" style="font-size:14px;line-height:22px;"><code class="hljs django has-numbering"><span class="xml" style="margin:0px;padding:0px;"></span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">include</span> template_name %}</span><span style="color:rgb(79,79,79);font-size:16px;text-align:justify;background-color:rgb(255,255,255);font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;"><span style="font-size:24px;"> </span></span></code></pre> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"></p> <p><strong><span style="font-size:18px;"><br></span></strong></p> <p><strong><span style="font-size:24px;">模板继承</span></strong></p> <p><strong><span style="font-size:24px;"><br></span></strong></p>本质上来说,模板继承就是先构造一个基础框架模板,而后在其子模板中对它所包含站点公用部分和定义块进行重载。  <br>就是说,比如每个网页都包含 <code style="font-size:14px;line-height:22px;padding:4px 2px 0px;"><HTML></HTML></code> 等重复的代码  <br> <strong>第一步是定义 基础模板</strong> , 该框架之后将由 子模板 所继承。 以下是我们目前所讲述范例的基础模板 <pre class="prettyprint" style="font-size:14px;line-height:22px;"><code class="hljs django has-numbering"><span class="xml" style="margin:0px;padding:0px;"><span class="hljs-doctype" style="margin:0px;padding:0px;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"></span> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">html</span> <span class="hljs-attribute" style="margin:0px;padding:0px;">lang</span>=<span class="hljs-value" style="margin:0px;padding:0px;">"en"</span>></span> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">head</span>></span> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">title</span>></span></span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">block</span> title %}</span><span class="xml" style="margin:0px;padding:0px;"></span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">endblock</span> %}</span><span class="xml" style="margin:0px;padding:0px;"><span class="hljs-tag" style="margin:0px;padding:0px;"></<span class="hljs-title" style="margin:0px;padding:0px;">title</span>></span> <span class="hljs-tag" style="margin:0px;padding:0px;"></<span class="hljs-title" style="margin:0px;padding:0px;">head</span>></span> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">body</span>></span> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">h1</span>></span>My helpful timestamp site<span class="hljs-tag" style="margin:0px;padding:0px;"></<span class="hljs-title" style="margin:0px;padding:0px;">h1</span>></span> </span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">block</span> content %}</span><span class="xml" style="margin:0px;padding:0px;"></span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">endblock</span> %}</span><span class="xml" style="margin:0px;padding:0px;"> </span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">block</span> footer %}</span><span class="xml" style="margin:0px;padding:0px;"> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">hr</span>></span> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">p</span>></span>Thanks for visiting my site.<span class="hljs-tag" style="margin:0px;padding:0px;"></<span class="hljs-title" style="margin:0px;padding:0px;">p</span>></span> </span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">endblock</span> %}</span><span class="xml" style="margin:0px;padding:0px;"> <span class="hljs-tag" style="margin:0px;padding:0px;"></<span class="hljs-title" style="margin:0px;padding:0px;">body</span>></span> <span class="hljs-tag" style="margin:0px;padding:0px;"></<span class="hljs-title" style="margin:0px;padding:0px;">html</span>></span></span></code></pre> <p>这个叫做 base.html 的模板定义了一个简单的 HTML 框架文档,我们将在本站点的所有页面中使用。<strong> </strong></p> <p><strong>子模板的作用就是重载、添加或保留那些块的内容。</strong> </p>我们使用一个以前已经见过的模板标签: {% block %} 。 所有的 {% block %} 标签告诉模板引擎,子模板可以重载这些部分。 每个{% block %}标签所要做的是告诉模板引擎,该模板下的这一块内容将有可能被子模板覆盖。  <br>现在我们已经有了一个基本模板,我们可以修改 current_datetime.html 模板来 使用它。 <pre class="prettyprint" style="font-size:14px;line-height:22px;"><code class="hljs django has-numbering"><span class="xml" style="margin:0px;padding:0px;"></span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">extends</span> "base.html" %}</span><span class="xml" style="margin:0px;padding:0px;"> </span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">block</span> title %}</span><span class="xml" style="margin:0px;padding:0px;">The current time</span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">endblock</span> %}</span><span class="xml" style="margin:0px;padding:0px;"> </span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">block</span> content %}</span><span class="xml" style="margin:0px;padding:0px;"> <span class="hljs-tag" style="margin:0px;padding:0px;"><<span class="hljs-title" style="margin:0px;padding:0px;">p</span>></span>It is now </span><span class="hljs-variable" style="margin:0px;padding:0px;">{{ current_date }}</span><span class="xml" style="margin:0px;padding:0px;">.<span class="hljs-tag" style="margin:0px;padding:0px;"></<span class="hljs-title" style="margin:0px;padding:0px;">p</span>></span> </span><span class="hljs-template_tag" style="margin:0px;padding:0px;">{% <span class="hljs-keyword" style="margin:0px;padding:0px;">endblock</span> %}</span></code></pre> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"><strong>模板引擎发现了 {% extends %} 标签, 注意到该模板是一个子模板。 模板引擎立即装载其父模板,即本例中的 base.html 。 </strong><br>模板引擎注意到 base.html 中的三个 {% block %} 标签,并用子模板的内容替换这些 block 。因此,引擎将会使用我们在 { block title %} 中定义的标题,对 {% block content %} 也是如此。 所以,网页标题一块将由 {% block title %}替换,同样地,网页的内容一块将由 {% block content %}替换。 <br></p> <p><strong>注意由于子模板并没有定义 footer 块,模板系统将使用在父模板中定义的值。</strong> 父模板 {% block %} 标签中的内容总是被当作一条退路。</p> <p><br></p> <p><br></p> <h2 style="color:rgb(51,51,51);margin-top:20px;margin-bottom:20px;line-height:1.5;padding:0px;font-family:Verdana, Arial, Helvetica, sans-serif;background-color:rgb(255,255,255);"></h2> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"><strong><span style="font-size:24px;">使用继承的一种常见方式是下面的三层法:</span></strong></p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">创建 base.html 模板,在其中定义站点的主要外观感受。 这些都是不常修改甚至从不修改的部分。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">为网站的每个区域创建 base_SECTION.html 模板(例如, base_photos.html 和 base_forum.html )。这些模板对 base.html 进行拓展,并包含区域特定的风格与设计。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">为每种类型的页面创建独立的模板,例如论坛页面或者图片库。 这些模板拓展相应的区域模板。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">这个方法可最大限度地重用代码,并使得向公共区域(如区域级的导航)添加内容成为一件轻松的工作。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"><br></p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"><br></p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"><strong><span style="font-size:24px;">以下是使用模板继承的一些诀窍:</span></strong></p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">如果在模板中使用 {% extends %} ,必须保证其为模板中的第一个模板标记。 否则,模板继承将不起作用。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">一般来说,基础模板中的 {% block %} 标签越多越好。 记住,子模板不必定义父模板中所有的代码块,因此你可以用合理的缺省值对一些代码块进行填充,然后只对子模板所需的代码块进行(重)定义。 俗话说,钩子越多越好。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">如果发觉自己在多个模板之间拷贝代码,你应该考虑将该代码段放置到父模板的某个 {% block %} 中。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">如果你需要访问父模板中的块的内容,使用 <strong>{{ block.super }}</strong>这个标签吧,这一个魔法变量将会表现出父模板中的内容。 如果只想在上级代码块基础上添加内容,而不是全部重载,该变量就显得非常有用了。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">不允许在同一个模板中定义多个同名的 {% block %} 。 存在这样的限制是因为<strong>block 标签的工作方式是双向的</strong>。 <strong>也就是说,block 标签不仅挖了一个要填的坑,也定义了在父模板中这个坑所填充的内容。</strong>如果模板中出现了两个相同名称的 {% block %} 标签,父模板将无从得知要使用哪个块的内容。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">{% extends %} 对所传入模板名称使用的加载方法和 get_template() 相同。 也就是说,会将模板名称被添加到 TEMPLATE_DIRS 设置之后。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">多数情况下, {% extends %} 的参数应该是字符串,但是如果直到运行时方能确定父模板名,这个参数也可以是个变量。 这使得你能够实现一些很酷的动态功能。</p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"><br></p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"><br></p> <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);"></p> <p><span style="font-size:18px;"><span style="font-weight:700;">如何在视图中使用模板</span> </span></p>模版是以Html形式显示的。要在django中使用,首先要告诉模版存放在那里。也就是模版加载。打开你的settings.py配置文件,配置如下:  <br> <img src="http://img.e-com-net.com/image/info8/c905cfe2894d4edc8c252eab8464e6c6.jpg" alt="这里写图片描述" title="" style="border:0px;margin-top:24px;margin-bottom:24px;" width="0" height="0"> <br>你可以任意指定想要的目录,只要运行 Web 服务器的用户可以读取该目录的子目录和模板文件 <p style="font-family:'-apple-system', 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun;background-color:rgb(255,255,255);">使用方式: <br>1.render <br>2.render_to_response <br>3.get_template() <br>个人比较支持第1和2的方式 <br><img src="http://img.e-com-net.com/image/info8/fa82e6a5e108468aa11f02783fe81783.jpg" alt="这里写图片描述" title="" style="border:0px;margin-top:24px;margin-bottom:24px;" width="0" height="0"></p> <br> </div> </div> </div> </div> </div> <!--PC和WAP自适应版--> <div id="SOHUCS" sid="1276084840105525248"></div> <script type="text/javascript" src="/views/front/js/chanyan.js"></script> <!-- 文章页-底部 动态广告位 --> <div class="youdao-fixed-ad" id="detail_ad_bottom"></div> </div> <div class="col-md-3"> <div class="row" id="ad"> <!-- 文章页-右侧1 动态广告位 --> <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_1"> </div> </div> <!-- 文章页-右侧2 动态广告位 --> <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_2"></div> </div> <!-- 文章页-右侧3 动态广告位 --> <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_3"></div> </div> </div> </div> </div> </div> </div> <div class="container"> <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(Django)</h4> <div id="paradigm-article-related"> <div class="recommend-post mb30"> <ul class="widget-links"> <li><a href="/article/1835408447806468096.htm" title="Ubuntu18.04 Docker部署Kinship(Django)项目过程" target="_blank">Ubuntu18.04 Docker部署Kinship(Django)项目过程</a> <span class="text-muted">Dante617</span> <div>1Docker的安装https://blog.csdn.net/weixin_41735055/article/details/1003551792下载镜像dockerpullprogramize/python3.6.8-dlib下载的镜像里包含python3.6.8和dlib19.17.03启动镜像dockerrun-it--namekinship-p7777:80-p3307:3306-p55</div> </li> <li><a href="/article/1835259969000271872.htm" title="软件测试/测试开发/全日制 |利用Django REST framework构建微服务" target="_blank">软件测试/测试开发/全日制 |利用Django REST framework构建微服务</a> <span class="text-muted">霍格沃兹-慕漓</span> <a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/%E5%BE%AE%E6%9C%8D%E5%8A%A1/1.htm">微服务</a><a class="tag" taget="_blank" href="/search/sqlite/1.htm">sqlite</a> <div>霍格沃兹测试开发学社推出了《Python全栈开发与自动化测试班》。本课程面向开发人员、测试人员与运维人员,课程内容涵盖Python编程语言、人工智能应用、数据分析、自动化办公、平台开发、UI自动化测试、接口测试、性能测试等方向。为大家提供更全面、更深入、更系统化的学习体验,课程还增加了名企私教服务内容,不仅有名企经理为你1v1辅导,还有行业专家进行技术指导,针对性地解决学习、工作中遇到的难题。让找</div> </li> <li><a href="/article/1835210184419536896.htm" title="锋哥写一套前后端分离Python权限系统 基于Django5+DRF+Vue3.2+Element Plus+Jwt 视频教程 ,帅呆了~~" target="_blank">锋哥写一套前后端分离Python权限系统 基于Django5+DRF+Vue3.2+Element Plus+Jwt 视频教程 ,帅呆了~~</a> <span class="text-muted">java1234_小锋</span> <a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/%E6%9D%83%E9%99%90%E7%B3%BB%E7%BB%9F/1.htm">权限系统</a><a class="tag" taget="_blank" href="/search/django%E6%9D%83%E9%99%90%E7%B3%BB%E7%BB%9F/1.htm">django权限系统</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/web%E6%9D%83%E9%99%90%E7%B3%BB%E7%BB%9F/1.htm">web权限系统</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/DRF/1.htm">DRF</a><a class="tag" taget="_blank" href="/search/VUE%E6%9D%83%E9%99%90/1.htm">VUE权限</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a> <div>大家好,我是java1234_小锋老师,最近写了一套【前后端分离Python权限系统基于Django5+DRF+Vue3.2+ElementPlus+Jwt】视频教程,持续更新中,计划月底更新完,感谢支持。视频在线地址:打造前后端分离Python权限系统基于Django5+DRF+Vue3.2+ElementPlus+Jwt视频教程(火爆连载更新中..)_哔哩哔哩_bilibili项目介绍本课程采</div> </li> <li><a href="/article/1835178538907561984.htm" title="2.8.5Django --8.2 单表操作" target="_blank">2.8.5Django --8.2 单表操作</a> <span class="text-muted">寒暄_HX</span> <div>Django目录:https://www.jianshu.com/p/dc36f62b3dc5Yuan先生-Django模型层(1)Django与SQLAlchemy的ORM操作本质上是一样的,但是语法略有不同,如果是用Django进行开发最好使用原生的ORM或者直接使用原生SQL。创建表app06创建模型在app06中的models.py文件内,新建一个模板。one_exa.app06.mode</div> </li> <li><a href="/article/1835165891906596864.htm" title="关于django中几个重要的gunicorn worker的配置" target="_blank">关于django中几个重要的gunicorn worker的配置</a> <span class="text-muted">给我起把狙</span> <a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/gunicorn/1.htm">gunicorn</a> <div>关于django中几个重要的gunicornworker的配置一、worker_classworker_class是Gunicorn的配置参数之一,它指定了工作进程(worker)的类型。不同的worker_class提供了不同的并发模型,适合不同类型的应用场景。sync和gevent是两种常见的worker_class,它们的作用和区别如下:1.sync(同步worker)默认值:如果没有指定w</div> </li> <li><a href="/article/1835165892321832960.htm" title="gunicorn未重启,导致代码没拉到最新问题。" target="_blank">gunicorn未重启,导致代码没拉到最新问题。</a> <span class="text-muted">给我起把狙</span> <a class="tag" taget="_blank" href="/search/gunicorn/1.htm">gunicorn</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>问题描述:我的测试环境的django项目是用gunicorn启动的,然后我本地使用pythonmanagy.py启动的,新写了个接口,在本地测试没问题,在测试环境报404。我发现发了最新代码到远端,然后我在测试环境pull下来的时候出问题了,代码不是最新的,后来我的经理告诉我说要重启gunicorn的主进程给了我一条指令"kill-HUPgunicorn_pid(最小的)”,针对这个问题我大致做了</div> </li> <li><a href="/article/1835019650895802368.htm" title="python基于django/flask的NBA球员大数据分析与可视化python+java+node.js" target="_blank">python基于django/flask的NBA球员大数据分析与可视化python+java+node.js</a> <span class="text-muted">QQ_511008285</span> <a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/flask/1.htm">flask</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a> <div>前端开发框架:vue.js数据库mysql版本不限后端语言框架支持:1java(SSM/springboot)-idea/eclipse2.Nodejs+Vue.js-vscode3.python(flask/django)--pycharm/vscode4.php(thinkphp/laravel)-hbuilderx数据库工具:Navicat/SQLyog等都可以本文针对NBA球员的大数据进行</div> </li> <li><a href="/article/1835019524521422848.htm" title="Java基于spring boot的国产电影数据分析与可视化python+java+node.js" target="_blank">Java基于spring boot的国产电影数据分析与可视化python+java+node.js</a> <span class="text-muted">QQ_511008285</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/flask/1.htm">flask</a> <div>前端开发框架:vue.js数据库mysql版本不限后端语言框架支持:1java(SSM/springboot)-idea/eclipse2.Nodejs+Vue.js-vscode3.python(flask/django)--pycharm/vscode4.php(thinkphp/laravel)-hbuilderx数据库工具:Navicat/SQLyog等都可以  该系统使用进行大数据处理和</div> </li> <li><a href="/article/1834965554214039552.htm" title="分布式框架Celery七(Django-Celery-Flower实现异步和定时爬虫及其监控邮件告警)" target="_blank">分布式框架Celery七(Django-Celery-Flower实现异步和定时爬虫及其监控邮件告警)</a> <span class="text-muted">yjjpp2301</span> <a class="tag" taget="_blank" href="/search/Celery/1.htm">Celery</a><a class="tag" taget="_blank" href="/search/%E5%88%86%E5%B8%83%E5%BC%8F/1.htm">分布式</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a> <div>Django中集成方式安装模块pipinstallDjango==3.2.22pipinstallcelerypipinstallredispipinstalleventlet#在windows环境下需要安装eventlet包-----------pipinstalldjango-celery-beatpipinstalldjango-celery-resultspipinstalldjango-</div> </li> <li><a href="/article/1834906052047499264.htm" title="基于django+vue代驾管理系统【开题报告+程序+论文】-计算机毕设" target="_blank">基于django+vue代驾管理系统【开题报告+程序+论文】-计算机毕设</a> <span class="text-muted">zhjie102</span> <a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/%E8%AF%BE%E7%A8%8B%E8%AE%BE%E8%AE%A1/1.htm">课程设计</a> <div>本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表开题报告内容研究背景随着城市化进程的加速和人们生活水平的提高,私家车数量急剧增加,但随之而来的酒驾问题也日益严峻,严重威胁着道路交通安全与公众生命财产安全。为了有效遏制酒驾行为,代驾服务应运而生并迅速普及。然而,当前市场上的代驾服务大多依赖于电话预约、人工调度等传统方式,存在效率低下</div> </li> <li><a href="/article/1834897607902720000.htm" title="Python+Django毕业设计校园易购二手交易平台(程序+LW+部署)" target="_blank">Python+Django毕业设计校园易购二手交易平台(程序+LW+部署)</a> <span class="text-muted">Python、JAVA毕设程序源码</span> <a class="tag" taget="_blank" href="/search/%E8%AF%BE%E7%A8%8B%E8%AE%BE%E8%AE%A1/1.htm">课程设计</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a> <div>项目运行环境配置:Jdk1.8+Tomcat7.0+Mysql+HBuilderX(Webstorm也行)+Eclispe(IntelliJIDEA,Eclispe,MyEclispe,Sts都支持)。项目技术:SSM+mybatis+Maven+Vue等等组成,B/S模式+Maven管理等等。环境需要1.运行环境:最好是javajdk1.8,我们在这个平台上运行的。其他版本理论上也可以。2.ID</div> </li> <li><a href="/article/1834880085786718208.htm" title="python毕业设计作品:python闲置物品二手交易平台系统设计与实现毕业设计源代码(Django框架)" target="_blank">python毕业设计作品:python闲置物品二手交易平台系统设计与实现毕业设计源代码(Django框架)</a> <span class="text-muted">黄菊华老师</span> <a class="tag" taget="_blank" href="/search/%E6%AF%95%E8%AE%BE%E8%B5%84%E6%96%99/1.htm">毕设资料</a><a class="tag" taget="_blank" href="/search/python%E4%BA%8C%E6%89%8B%E4%BA%A4%E6%98%93%E5%B9%B3%E5%8F%B0%E7%B3%BB%E7%BB%9F/1.htm">python二手交易平台系统</a> <div>博主介绍:黄菊华老师《Vue.js入门与商城开发实战》《微信小程序商城开发》图书作者,CSDN博客专家,在线教育专家,CSDN钻石讲师;专注大学生毕业设计教育和辅导。所有项目都配有从入门到精通的基础知识视频课程,学习后应对毕业设计答辩。项目配有对应开发文档、开题报告、任务书、PPT、论文模版等项目都录了发布和功能操作演示视频;项目的界面和功能都可以定制,包安装运行!!!如果需要联系我,可以在CSD</div> </li> <li><a href="/article/1834793356543225856.htm" title="由于篇幅和复杂性限制,我无法在这里直接为你提供一个完整的、用多种编程语言实现的购物商城代码。但是,我可以为你概述如何使用几种流行的编程语言(如Python, JavaScript/Node.js, J" target="_blank">由于篇幅和复杂性限制,我无法在这里直接为你提供一个完整的、用多种编程语言实现的购物商城代码。但是,我可以为你概述如何使用几种流行的编程语言(如Python, JavaScript/Node.js, J</a> <span class="text-muted">NewmanEdwarda2</span> <a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a> <div>Python(后端,使用Flask或Django)Flask示例(后端API)gjijg.compythonfromflaskimportFlask,request,jsonifyapp=Flask(name)假设的数据库商品列表products=[{“id”:1,“name”:“苹果”,“price”:10.0},{“id”:2,“name”:“香蕉”,“price”:5.0},]@app.ro</div> </li> <li><a href="/article/1834739283336982528.htm" title="Django 安装指南" target="_blank">Django 安装指南</a> <span class="text-muted">lly202406</span> <a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a> <div>Django安装指南Django是一个高级的PythonWeb框架,它鼓励快速开发和干净、实用的设计。本指南将详细介绍如何在不同的操作系统上安装Django,包括Windows、macOS和Linux。在Windows上安装Django先决条件Python:Django要求Python3.8或更高版本。可以从Python官网下载适用于Windows的Python安装程序。pip:Python的包管</div> </li> <li><a href="/article/1834573267847966720.htm" title="基于Python爬虫四川成都二手房数据可视化系统设计与实现(Django框架) 研究背景与意义、国内外研究现状_django商品房数据分析论文(1)" target="_blank">基于Python爬虫四川成都二手房数据可视化系统设计与实现(Django框架) 研究背景与意义、国内外研究现状_django商品房数据分析论文(1)</a> <span class="text-muted">莫莫Android开发</span> <a class="tag" taget="_blank" href="/search/%E4%BF%A1%E6%81%AF%E5%8F%AF%E8%A7%86%E5%8C%96/1.htm">信息可视化</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E7%88%AC%E8%99%AB/1.htm">爬虫</a> <div>3.国外研究现状在国外,二手房数据可视化也是一个热门的研究领域。以美国为例,有很多公司和网站提供了专门的二手房数据可视化工具,如Zillow、Redfin等。这些工具通常提供房价趋势图、房价分布图、房源信息等功能,帮助用户更好地了解房市动态。综上所述,虽然国内外在二手房数据可视化方面已经有了一些研究成果,但对于四川成都地区的二手房市场还没有相关的研究和可视化系统。因此,本研究旨在设计并实现一个基于</div> </li> <li><a href="/article/1834551847789096960.htm" title="django中F()和Q()的用法" target="_blank">django中F()和Q()的用法</a> <span class="text-muted">给我起把狙</span> <a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a> <div>django中F()和Q()的用法一、F()表达式的详细介绍1.基本概念:F()表达式用于引用模型中的字段,允许你直接在数据库层面进行计算、比较或更新操作,而不需要将数据加载到Python内存中进行操作。这样可以提高性能,避免racecondition(数据竞争)。2.常见用法:1.字段间运算:你可以使用F()对同一记录中的不同字段进行运算。比如,你有一个模型Product,其中包含price和d</div> </li> <li><a href="/article/1834550710818140160.htm" title="Django 开发实战 2-2 模型 -创建模型类" target="_blank">Django 开发实战 2-2 模型 -创建模型类</a> <span class="text-muted">爱之泪伤</span> <a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/1.htm">项目实战</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/ubuntu/1.htm">ubuntu</a><a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C/1.htm">网络</a> <div>python开发实战-创建模型类一、介绍:二、根据迁移文件生成映射书库据表。三、查看数据库是否根据牵引文件的需求生成数据库,因此返回终端去连接`filmdatabase`数据库。四、最后,了解一些数据库的知识说明。一、介绍:  模型类被创建在"应用目录/models.py"文件中。模型类必须继承自Model类,位于包dango.db.models中。接下来首先以"影片-人物"管理为例进行演示。1定</div> </li> <li><a href="/article/1834550457662533632.htm" title="Vue + Django的人脸识别系统" target="_blank">Vue + Django的人脸识别系统</a> <span class="text-muted">DXSsssss</span> <a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/DRF/1.htm">DRF</a><a class="tag" taget="_blank" href="/search/tensorflow/1.htm">tensorflow</a><a class="tag" taget="_blank" href="/search/%E4%BA%BA%E8%84%B8%E8%AF%86%E5%88%AB/1.htm">人脸识别</a> <div>最近在研究机器学习,刚好最近看了vue+Djangodrf的一些课程,学以致用,做了一个人脸识别系统。项目前端使用Vue框架,用到了elementui组件,写起来真是方便。比之前传统的dtl方便了太多。后端使用了drf,识别知识刚开始打算使用opencv+tensorflow,但是发现吧识别以后的结果返回到浏览器当中时使用opencv比较麻烦(主要是我太菜,想不到比较好的方法),因此最终使用了tf</div> </li> <li><a href="/article/1834550454785241088.htm" title="Django 创建好的模块怎么在后台显示" target="_blank">Django 创建好的模块怎么在后台显示</a> <span class="text-muted">u010373106</span> <a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/Django/1.htm">Django</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/sqlite/1.htm">sqlite</a> <div>1、配置模型及其需要显示的数据刚才创建好的tests的增删改查,在后台是不显示的,所以需要进行配置,在刚才创建好的模块里找到admin.py文件,在里面进行如下配置fromdjango.contribimportadminfrom.importmodelsfrom.modelsimportTests#Registeryourmodelshere.classTestsAdmin(admin.Mode</div> </li> <li><a href="/article/1834541635233476608.htm" title="【django】创建模型类(已更新)" target="_blank">【django】创建模型类(已更新)</a> <span class="text-muted">敲代码敲到头发茂密</span> <a class="tag" taget="_blank" href="/search/Django/1.htm">Django</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/ORM%E6%A1%86%E6%9E%B6/1.htm">ORM框架</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a> <div>ORM框架一、创建模型类二、字段类型说明三、字段选项说明四、外键五、迁移六、添加测试数据a、数据库:需要提前手动创建数据库b、数据表:与ORM框架中的模型类一一对应c、字段:模型类中的类属性(Field子类)d、记录:类似于模型类的多个实例一、创建模型类模型类创建在应用目录/models.py文件中。模型类必须继承Model类,位于包django.db.models中。接下来首先以“影片-人物”管</div> </li> <li><a href="/article/1834535205646462976.htm" title="Django+Vue基于OpenCV的人脸识别系统的设计与实现" target="_blank">Django+Vue基于OpenCV的人脸识别系统的设计与实现</a> <span class="text-muted">赵广陆</span> <a class="tag" taget="_blank" href="/search/project/1.htm">project</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/opencv/1.htm">opencv</a> <div>目录1项目介绍2项目截图3核心代码3.1需要的环境3.2Django接口层3.3实体类3.4config.ini3.5启动类3.5Vue4数据库表设计5文档参考6计算机毕设选题推荐7源码获取1项目介绍博主个人介绍:CSDN认证博客专家,CSDN平台Java领域优质创作者,全网30w+粉丝,超300w访问量,专注于大学生项目实战开发、讲解和答疑辅导,对于专业性数据证明一切!主要项目:javaweb、</div> </li> <li><a href="/article/1834400467820572672.htm" title="Django核心面试题" target="_blank">Django核心面试题</a> <span class="text-muted">闲人编程</span> <a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98%E9%9D%A2%E8%AF%95/1.htm">程序员面试</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a> <div>Django核心面试题Django核心面试题Django核心面试题1.Django的MVT架构是什么?2.如何创建Django项目和应用?3.DjangoORM是什么?4.什么是Django的middleware?举例说明。5.Django中的静态文件如何处理?6.如何定义Django模型?7.什么是Django的QuerySet?如何使用?8.如何进行Django的数据库迁移?9.Django中</div> </li> <li><a href="/article/1834367946206572544.htm" title="Django——多apps目录情况下的app注册" target="_blank">Django——多apps目录情况下的app注册</a> <span class="text-muted">叫我DPT</span> <a class="tag" taget="_blank" href="/search/Django%E6%A1%86%E6%9E%B6%E7%9F%A5%E8%AF%86%E7%82%B9/1.htm">Django框架知识点</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a> <div>文章目录多apps目录下的app注册方式1-添加python导包路径方式2-修改AppConfig类名多apps目录下的app注册方式1-添加python导包路径importsyssys.path.insert(0,str(BASE_DIR/"apps"))print(sys.path)INSTALLED_APPS=['django.contrib.admin','django.contrib.a</div> </li> <li><a href="/article/1834367819840581632.htm" title="Django项目中log日志的配置" target="_blank">Django项目中log日志的配置</a> <span class="text-muted">叫我DPT</span> <a class="tag" taget="_blank" href="/search/Django%E9%A1%B9%E7%9B%AE%E4%B8%AD%E5%B8%B8%E7%94%A8%E7%BB%84%E4%BB%B6/1.htm">Django项目中常用组件</a><a class="tag" taget="_blank" href="/search/%E8%84%9A%E6%9C%AC/1.htm">脚本</a><a class="tag" taget="_blank" href="/search/%E5%8A%9F%E8%83%BD/1.htm">功能</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/logging/1.htm">logging</a> <div>文章目录日志配置模板日志处理器Handlers日志配置模板#日志LOGGING={'version':1,#使用的日志模块的版本,目前官方提供的只有版本1,但是官方有可能会升级,为了避免升级出现的版本问题,所以这里固定为1'disable_existing_loggers':False,#是否禁用其他的已经存在的日志功能?肯定不能,有可能有些第三方模块在调用,所以禁用了以后,第三方模块无法捕获自身</div> </li> <li><a href="/article/1834285986738171904.htm" title="Django:Python高级Web框架详解及参数设置" target="_blank">Django:Python高级Web框架详解及参数设置</a> <span class="text-muted">零 度°</span> <a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a> <div>Django是一个高级的PythonWeb框架,它鼓励快速开发和简洁实用的设计。Django遵循MVC设计模式,提供了一套完整的解决方案,用于构建复杂的、数据库驱动的网站。Django的主要特点自动管理数据库:通过ORM(对象关系映射)自动管理数据库。自动生成站点地图:支持搜索引擎优化(SEO)。用户身份认证:内置用户认证系统。中间件支持:强大的中间件支持,可以处理请求和响应。跨站请求伪造(CSR</div> </li> <li><a href="/article/1834190698161729536.htm" title="Python轻量级ORM框架——peewee" target="_blank">Python轻量级ORM框架——peewee</a> <span class="text-muted">半生浮名只是虚妄</span> <a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a> <div>这里写目录标题Python中常用的ORM框架peewee使用经验从数据库中导出模型查询统计类查询优化子查询参考文章Python中常用的ORM框架SQLALchemy:重量级框架,适合企业级开发,容易与任意Web框架集成,学习成本更高DjangoORM:Django框架中内嵌的ORM模块,易学易用,只适合Django项目使用peewee:轻量级框架,适合个人开发,容易与任意Web框架集成,API类似</div> </li> <li><a href="/article/1833937451014516736.htm" title="Ubuntu系统nginx和uwsgi常用命令(部署网站相关命令)" target="_blank">Ubuntu系统nginx和uwsgi常用命令(部署网站相关命令)</a> <span class="text-muted">我不是大佬zvj</span> <a class="tag" taget="_blank" href="/search/ubuntu/1.htm">ubuntu</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>以下是我自己在学习使用Ubuntu操作系统部署pythonflask和django网站时常用的命令,作为学习笔记,记录一下,写的比较简单,还有啥需要补充的话欢迎留言。路径相关#进入项目路径cd /var/www/html/Podcaster#nginx配置文件路径‏/etc/nginx/sites-enabled/‌‍default防火墙#查看已经开放的端口sudoufwstatus#打开端口su</div> </li> <li><a href="/article/1833814523505635328.htm" title="2025毕业设计指南:如何用Hadoop构建超市进货推荐系统?大数据分析助力精准采购" target="_blank">2025毕业设计指南:如何用Hadoop构建超市进货推荐系统?大数据分析助力精准采购</a> <span class="text-muted">计算机编程指导师</span> <a class="tag" taget="_blank" href="/search/Java%E5%AE%9E%E6%88%98%E9%9B%86/1.htm">Java实战集</a><a class="tag" taget="_blank" href="/search/Python%E5%AE%9E%E6%88%98%E9%9B%86/1.htm">Python实战集</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%AE%9E%E6%88%98%E9%9B%86/1.htm">大数据实战集</a><a class="tag" taget="_blank" href="/search/%E8%AF%BE%E7%A8%8B%E8%AE%BE%E8%AE%A1/1.htm">课程设计</a><a class="tag" taget="_blank" href="/search/hadoop/1.htm">hadoop</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E8%BF%9B%E8%B4%A7/1.htm">进货</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a> <div>✍✍计算机编程指导师⭐⭐个人介绍:自己非常喜欢研究技术问题!专业做Java、Python、小程序、安卓、大数据、爬虫、Golang、大屏等实战项目。⛽⛽实战项目:有源码或者技术上的问题欢迎在评论区一起讨论交流!⚡⚡Java实战|SpringBoot/SSMPython实战项目|Django微信小程序/安卓实战项目大数据实战项目⚡⚡文末获取源码文章目录⚡⚡文末获取源码基于hadoop的超市进货推荐系</div> </li> <li><a href="/article/1833706099132428288.htm" title="Python Web 框架篇:Flask、Django、FastAPI介绍及其核心技术" target="_blank">Python Web 框架篇:Flask、Django、FastAPI介绍及其核心技术</a> <span class="text-muted">Switch616</span> <a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/Web/1.htm">Web</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/flask/1.htm">flask</a><a class="tag" taget="_blank" href="/search/fastapi/1.htm">fastapi</a><a class="tag" taget="_blank" href="/search/django/1.htm">django</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a> <div>PythonWeb框架篇:Flask、Django、FastAPI介绍及其核心技术目录FlaskFlask核心概念(路由、视图函数、模板渲染)FlaskBlueprint模块化应用Flask扩展(Flask-SQLAlchemy、Flask-WTF、Flask-Migrate等)DjangoDjango项目架构DjangoORM及模型定义Django中间件Django信号机制DjangoForm和</div> </li> <li><a href="/article/1833702066061668352.htm" title="python selenium post,是否可以在Selenium中捕获POST数据?" target="_blank">python selenium post,是否可以在Selenium中捕获POST数据?</a> <span class="text-muted">weixin_39600328</span> <a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/selenium/1.htm">selenium</a><a class="tag" taget="_blank" href="/search/post/1.htm">post</a> <div>I'mworkingwiththeSeleniumWebDriverToolandamwonderingifthistoolprovidesameansforcapturingthePOSTdatageneratedwhensubmittingaform.I'musingthedjangotestframeworktotestthatmydataisprocessedcorrectlyontheb</div> </li> <li><a href="/article/55.htm" title="多线程编程之卫生间" target="_blank">多线程编程之卫生间</a> <span class="text-muted">周凡杨</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%B9%B6%E5%8F%91/1.htm">并发</a><a class="tag" taget="_blank" href="/search/%E5%8D%AB%E7%94%9F%E9%97%B4/1.htm">卫生间</a><a class="tag" taget="_blank" href="/search/%E7%BA%BF%E7%A8%8B/1.htm">线程</a><a class="tag" taget="_blank" href="/search/%E5%8E%95%E6%89%80/1.htm">厕所</a> <div>如大家所知,火车上车厢的卫生间很小,每次只能容纳一个人,一个车厢只有一个卫生间,这个卫生间会被多个人同时使用,在实际使用时,当一个人进入卫生间时则会把卫生间锁上,等出来时打开门,下一个人进去把门锁上,如果有一个人在卫生间内部则别人的人发现门是锁的则只能在外面等待。问题分析:首先问题中有两个实体,一个是人,一个是厕所,所以设计程序时就可以设计两个类。人是多数的,厕所只有一个(暂且模拟的是一个车厢)。</div> </li> <li><a href="/article/182.htm" title="How to Install GUI to Centos Minimal" target="_blank">How to Install GUI to Centos Minimal</a> <span class="text-muted">sunjing</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/Install/1.htm">Install</a><a class="tag" taget="_blank" href="/search/Desktop/1.htm">Desktop</a><a class="tag" taget="_blank" href="/search/GUI/1.htm">GUI</a> <div>http://www.namhuy.net/475/how-to-install-gui-to-centos-minimal.html   I have centos 6.3 minimal running as web server. I’m looking to install gui to my server to vnc to my server. You can insta</div> </li> <li><a href="/article/309.htm" title="Shell 函数" target="_blank">Shell 函数</a> <span class="text-muted">daizj</span> <a class="tag" taget="_blank" href="/search/shell/1.htm">shell</a><a class="tag" taget="_blank" href="/search/%E5%87%BD%E6%95%B0/1.htm">函数</a> <div>Shell 函数 linux shell 可以用户定义函数,然后在shell脚本中可以随便调用。 shell中函数的定义格式如下: [function] funname [()]{ action; [return int;] } 说明: 1、可以带function fun() 定义,也可以直接fun() 定义,不带任何参数。 2、参数返回</div> </li> <li><a href="/article/436.htm" title="Linux服务器新手操作之一" target="_blank">Linux服务器新手操作之一</a> <span class="text-muted">周凡杨</span> <a class="tag" taget="_blank" href="/search/Linux+%E7%AE%80%E5%8D%95+%E6%93%8D%E4%BD%9C/1.htm">Linux 简单 操作</a> <div>1.whoami      当一个用户登录Linux系统之后,也许他想知道自己是发哪个用户登录的。      此时可以使用whoami命令。      [ecuser@HA5-DZ05 ~]$ whoami       e</div> </li> <li><a href="/article/563.htm" title="浅谈Socket通信(一)" target="_blank">浅谈Socket通信(一)</a> <span class="text-muted">朱辉辉33</span> <a class="tag" taget="_blank" href="/search/socket/1.htm">socket</a> <div>在java中ServerSocket用于服务器端,用来监听端口。通过服务器监听,客户端发送请求,双方建立链接后才能通信。当服务器和客户端建立链接后,两边都会产生一个Socket实例,我们可以通过操作Socket来建立通信。    首先我建立一个ServerSocket对象。当然要导入java.net.ServerSocket包    ServerSock</div> </li> <li><a href="/article/690.htm" title="关于框架的简单认识" target="_blank">关于框架的简单认识</a> <span class="text-muted">西蜀石兰</span> <a class="tag" taget="_blank" href="/search/%E6%A1%86%E6%9E%B6/1.htm">框架</a> <div>入职两个月多,依然是一个不会写代码的小白,每天的工作就是看代码,写wiki。 前端接触CSS、HTML、JS等语言,一直在用的CS模型,自然免不了数据库的链接及使用,真心涉及框架,项目中用到的BootStrap算一个吧,哦,JQuery只能算半个框架吧,我更觉得它是另外一种语言。 后台一直是纯Java代码,涉及的框架是Quzrtz和log4j。 都说学前端的要知道三大框架,目前node.</div> </li> <li><a href="/article/817.htm" title="You have an error in your SQL syntax; check the manual that corresponds to your" target="_blank">You have an error in your SQL syntax; check the manual that corresponds to your</a> <span class="text-muted">林鹤霄</span> <div>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option,changed_ids  ) values('0ac91f167f754c8cbac00e9e3dc372</div> </li> <li><a href="/article/944.htm" title="MySQL5.6的my.ini配置" target="_blank">MySQL5.6的my.ini配置</a> <span class="text-muted">aigo</span> <a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a> <div>注意:以下配置的服务器硬件是:8核16G内存    [client]   port=3306   [mysql]   default-character-set=utf8     [mysqld]   port=3306   basedir=D:/mysql-5.6.21-win</div> </li> <li><a href="/article/1071.htm" title="mysql 全文模糊查找 便捷解决方案" target="_blank">mysql 全文模糊查找 便捷解决方案</a> <span class="text-muted">alxw4616</span> <a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a> <div>mysql 全文模糊查找 便捷解决方案 2013/6/14 by 半仙 alxw4616@Msn.com 目的: 项目需求实现模糊查找. 原则: 查询不能超过 1秒. 问题: 目标表中有超过1千万条记录. 使用like '%str%' 进行模糊查询无法达到性能需求. 解决方案: 使用mysql全文索引. 1.全文索引 : MySQL支持全文索引和搜索功能。MySQL中的全文索</div> </li> <li><a href="/article/1198.htm" title="自定义数据结构 链表(单项 ,双向,环形)" target="_blank">自定义数据结构 链表(单项 ,双向,环形)</a> <span class="text-muted">百合不是茶</span> <a class="tag" taget="_blank" href="/search/%E5%8D%95%E9%A1%B9%E9%93%BE%E8%A1%A8/1.htm">单项链表</a><a class="tag" taget="_blank" href="/search/%E5%8F%8C%E5%90%91%E9%93%BE%E8%A1%A8/1.htm">双向链表</a> <div>     链表与动态数组的实现方式差不多,    数组适合快速删除某个元素    链表则可以快速的保存数组并且可以是不连续的       单项链表;数据从第一个指向最后一个   实现代码:        //定义动态链表 clas</div> </li> <li><a href="/article/1325.htm" title="threadLocal实例" target="_blank">threadLocal实例</a> <span class="text-muted">bijian1013</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/thread/1.htm">thread</a><a class="tag" taget="_blank" href="/search/java%E5%A4%9A%E7%BA%BF%E7%A8%8B/1.htm">java多线程</a><a class="tag" taget="_blank" href="/search/threadLocal/1.htm">threadLocal</a> <div>实例1: package com.bijian.thread; public class MyThread extends Thread { private static ThreadLocal tl = new ThreadLocal() { protected synchronized Object initialValue() { return new Inte</div> </li> <li><a href="/article/1452.htm" title="activemq安全设置—设置admin的用户名和密码" target="_blank">activemq安全设置—设置admin的用户名和密码</a> <span class="text-muted">bijian1013</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/activemq/1.htm">activemq</a> <div>        ActiveMQ使用的是jetty服务器, 打开conf/jetty.xml文件,找到 <bean id="adminSecurityConstraint" class="org.eclipse.jetty.util.security.Constraint"> <p</div> </li> <li><a href="/article/1579.htm" title="【Java范型一】Java范型详解之范型集合和自定义范型类" target="_blank">【Java范型一】Java范型详解之范型集合和自定义范型类</a> <span class="text-muted">bit1129</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a> <div>本文详细介绍Java的范型,写一篇关于范型的博客原因有两个,前几天要写个范型方法(返回值根据传入的类型而定),竟然想了半天,最后还是从网上找了个范型方法的写法;再者,前一段时间在看Gson, Gson这个JSON包的精华就在于对范型的优雅简单的处理,看它的源代码就比较迷糊,只其然不知其所以然。所以,还是花点时间系统的整理总结下范型吧。   范型内容 范型集合类 范型类 </div> </li> <li><a href="/article/1706.htm" title="【HBase十二】HFile存储的是一个列族的数据" target="_blank">【HBase十二】HFile存储的是一个列族的数据</a> <span class="text-muted">bit1129</span> <a class="tag" taget="_blank" href="/search/hbase/1.htm">hbase</a> <div>在HBase中,每个HFile存储的是一个表中一个列族的数据,也就是说,当一个表中有多个列簇时,针对每个列簇插入数据,最后产生的数据是多个HFile,每个对应一个列族,通过如下操作验证   1. 建立一个有两个列族的表   create 'members','colfam1','colfam2'   2. 在members表中的colfam1中插入50*5</div> </li> <li><a href="/article/1833.htm" title="Nginx 官方一个配置实例" target="_blank">Nginx 官方一个配置实例</a> <span class="text-muted">ronin47</span> <a class="tag" taget="_blank" href="/search/nginx+%E9%85%8D%E7%BD%AE%E5%AE%9E%E4%BE%8B/1.htm">nginx 配置实例</a> <div>user www www; worker_processes 5; error_log logs/error.log; pid logs/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096;} http { include conf/mim</div> </li> <li><a href="/article/1960.htm" title="java-15.输入一颗二元查找树,将该树转换为它的镜像, 即在转换后的二元查找树中,左子树的结点都大于右子树的结点。 用递归和循环" target="_blank">java-15.输入一颗二元查找树,将该树转换为它的镜像, 即在转换后的二元查找树中,左子树的结点都大于右子树的结点。 用递归和循环</a> <span class="text-muted">bylijinnan</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a> <div> //use recursion public static void mirrorHelp1(Node node){ if(node==null)return; swapChild(node); mirrorHelp1(node.getLeft()); mirrorHelp1(node.getRight()); } //use no recursion bu</div> </li> <li><a href="/article/2087.htm" title="返回null还是empty" target="_blank">返回null还是empty</a> <span class="text-muted">bylijinnan</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/apache/1.htm">apache</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B/1.htm">编程</a> <div>第一个问题,函数是应当返回null还是长度为0的数组(或集合)? 第二个问题,函数输入参数不当时,是异常还是返回null? 先看第一个问题 有两个约定我觉得应当遵守: 1.返回零长度的数组或集合而不是null(详见《Effective Java》) 理由就是,如果返回empty,就可以少了很多not-null判断: List<Person> list</div> </li> <li><a href="/article/2214.htm" title="[科技与项目]工作流厂商的战略机遇期" target="_blank">[科技与项目]工作流厂商的战略机遇期</a> <span class="text-muted">comsci</span> <a class="tag" taget="_blank" href="/search/%E5%B7%A5%E4%BD%9C%E6%B5%81/1.htm">工作流</a> <div>       在新的战略平衡形成之前,这里有一个短暂的战略机遇期,只有大概最短6年,最长14年的时间,这段时间就好像我们森林里面的小动物,在秋天中,必须抓紧一切时间存储坚果一样,否则无法熬过漫长的冬季。。。。         在微软,甲骨文,谷歌,IBM,SONY</div> </li> <li><a href="/article/2341.htm" title="过度设计-举例" target="_blank">过度设计-举例</a> <span class="text-muted">cuityang</span> <a class="tag" taget="_blank" href="/search/%E8%BF%87%E5%BA%A6%E8%AE%BE%E8%AE%A1/1.htm">过度设计</a> <div>过度设计,需要更多设计时间和测试成本,如无必要,还是尽量简洁一些好。 未来的事情,比如 访问量,比如数据库的容量,比如是否需要改成分布式  都是无法预料的 再举一个例子,对闰年的判断逻辑:   1、 if($Year%4==0) return True; else return Fasle;   2、if (   ($Year%4==0  &am</div> </li> <li><a href="/article/2468.htm" title="java进阶,《Java性能优化权威指南》试读" target="_blank">java进阶,《Java性能优化权威指南》试读</a> <span class="text-muted">darkblue086</span> <a class="tag" taget="_blank" href="/search/java%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/1.htm">java性能优化</a> <div>记得当年随意读了微软出版社的.NET 2.0应用程序调试,才发现调试器如此强大,应用程序开发调试其实真的简单了很多,不仅仅是因为里面介绍了很多调试器工具的使用,更是因为里面寻找问题并重现问题的思想让我震撼,时隔多年,Java已经如日中天,成为许多大型企业应用的首选,而今天,这本《Java性能优化权威指南》让我再次找到了这种感觉,从不经意的开发过程让我刮目相看,原来性能调优不是简单地看看热点在哪里,</div> </li> <li><a href="/article/2595.htm" title="网络学习笔记初识OSI七层模型与TCP协议" target="_blank">网络学习笔记初识OSI七层模型与TCP协议</a> <span class="text-muted">dcj3sjt126com</span> <a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/1.htm">学习笔记</a> <div>  协议:在计算机网络中通信各方面所达成的、共同遵守和执行的一系列约定   计算机网络的体系结构:计算机网络的层次结构和各层协议的集合。   两类服务:   面向连接的服务通信双方在通信之前先建立某种状态,并在通信过程中维持这种状态的变化,同时为服务对象预先分配一定的资源。这种服务叫做面向连接的服务。   面向无连接的服务通信双方在通信前后不建立和维持状态,不为服务对象</div> </li> <li><a href="/article/2722.htm" title="mac中用命令行运行mysql" target="_blank">mac中用命令行运行mysql</a> <span class="text-muted">dcj3sjt126com</span> <a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/mac/1.htm">mac</a> <div>参考这篇博客:http://www.cnblogs.com/macro-cheng/archive/2011/10/25/mysql-001.html  感觉workbench不好用(有点先入为主了)。 1,安装mysql 在mysql的官方网站下载 mysql 5.5.23 http://www.mysql.com/downloads/mysql/,根据我的机器的配置情况选择了64</div> </li> <li><a href="/article/2849.htm" title="MongDB查询(1)——基本查询[五]" target="_blank">MongDB查询(1)——基本查询[五]</a> <span class="text-muted">eksliang</span> <a class="tag" taget="_blank" href="/search/mongodb/1.htm">mongodb</a><a class="tag" taget="_blank" href="/search/mongodb+%E6%9F%A5%E8%AF%A2/1.htm">mongodb 查询</a><a class="tag" taget="_blank" href="/search/mongodb+find/1.htm">mongodb find</a> <div>MongDB查询 转载请出自出处:http://eksliang.iteye.com/blog/2174452 一、find简介 MongoDB中使用find来进行查询。 API:如下 function ( query , fields , limit , skip, batchSize, options ){.....}  参数含义: query:查询参数 fie</div> </li> <li><a href="/article/2976.htm" title="base64,加密解密 经融加密,对接" target="_blank">base64,加密解密 经融加密,对接</a> <span class="text-muted">y806839048</span> <a class="tag" taget="_blank" href="/search/%E7%BB%8F%E8%9E%8D%E5%8A%A0%E5%AF%86/1.htm">经融加密</a><a class="tag" taget="_blank" href="/search/%E5%AF%B9%E6%8E%A5/1.htm">对接</a> <div>String data0 = new String(Base64.encode(bo.getPaymentResult().getBytes(("GBK")))); String data1 = new String(Base64.decode(data0.toCharArray()),"GBK"); // 注意编码格式,注意用于加密,解密的要是同</div> </li> <li><a href="/article/3103.htm" title="JavaWeb之JSP概述" target="_blank">JavaWeb之JSP概述</a> <span class="text-muted">ihuning</span> <a class="tag" taget="_blank" href="/search/javaweb/1.htm">javaweb</a> <div>  什么是JSP?为什么使用JSP? JSP表示Java Server Page,即嵌有Java代码的HTML页面。使用JSP是因为在HTML中嵌入Java代码比在Java代码中拼接字符串更容易、更方便和更高效。   JSP起源    在很多动态网页中,绝大部分内容都是固定不变的,只有局部内容需要动态产生和改变。  如果使用Servl</div> </li> <li><a href="/article/3230.htm" title="apple watch 指南" target="_blank">apple watch 指南</a> <span class="text-muted">啸笑天</span> <a class="tag" taget="_blank" href="/search/apple/1.htm">apple</a> <div>1. 文档 WatchKit Programming Guide(中译在线版 By @CocoaChina) 译文 译者 原文 概览 - 开始为 Apple Watch 进行开发 @星夜暮晨 Overview - Developing for Apple Watch 概览 - 配置 Xcode 项目 - Overview - Configuring Yo</div> </li> <li><a href="/article/3357.htm" title="java经典的基础题目" target="_blank">java经典的基础题目</a> <span class="text-muted">macroli</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B/1.htm">编程</a> <div>1.列举出 10个JAVA语言的优势 a:免费,开源,跨平台(平台独立性),简单易用,功能完善,面向对象,健壮性,多线程,结构中立,企业应用的成熟平台, 无线应用 2.列举出JAVA中10个面向对象编程的术语 a:包,类,接口,对象,属性,方法,构造器,继承,封装,多态,抽象,范型 3.列举出JAVA中6个比较常用的包 Java.lang;java.util;java.io;java.sql;ja</div> </li> <li><a href="/article/3484.htm" title="你所不知道神奇的js replace正则表达式" target="_blank">你所不知道神奇的js replace正则表达式</a> <span class="text-muted">qiaolevip</span> <a class="tag" taget="_blank" href="/search/%E6%AF%8F%E5%A4%A9%E8%BF%9B%E6%AD%A5%E4%B8%80%E7%82%B9%E7%82%B9/1.htm">每天进步一点点</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0%E6%B0%B8%E6%97%A0%E6%AD%A2%E5%A2%83/1.htm">学习永无止境</a><a class="tag" taget="_blank" href="/search/%E7%BA%B5%E8%A7%82%E5%8D%83%E8%B1%A1/1.htm">纵观千象</a><a class="tag" taget="_blank" href="/search/regex/1.htm">regex</a> <div>var v = 'C9CFBAA3CAD0'; console.log(v); var arr = v.split(''); for (var i = 0; i < arr.length; i ++) { if (i % 2 == 0) arr[i] = '%' + arr[i]; } console.log(arr.join('')); console.log(v.r</div> </li> <li><a href="/article/3611.htm" title="[一起学Hive]之十五-分析Hive表和分区的统计信息(Statistics)" target="_blank">[一起学Hive]之十五-分析Hive表和分区的统计信息(Statistics)</a> <span class="text-muted">superlxw1234</span> <a class="tag" taget="_blank" href="/search/hive/1.htm">hive</a><a class="tag" taget="_blank" href="/search/hive%E5%88%86%E6%9E%90%E8%A1%A8/1.htm">hive分析表</a><a class="tag" taget="_blank" href="/search/hive%E7%BB%9F%E8%AE%A1%E4%BF%A1%E6%81%AF/1.htm">hive统计信息</a><a class="tag" taget="_blank" href="/search/hive+Statistics/1.htm">hive Statistics</a> <div>关键字:Hive统计信息、分析Hive表、Hive Statistics   类似于Oracle的分析表,Hive中也提供了分析表和分区的功能,通过自动和手动分析Hive表,将Hive表的一些统计信息存储到元数据中。   表和分区的统计信息主要包括:行数、文件数、原始数据大小、所占存储大小、最后一次操作时间等;   14.1 新表的统计信息 对于一个新创建</div> </li> <li><a href="/article/3738.htm" title="Spring Boot 1.2.5 发布" target="_blank">Spring Boot 1.2.5 发布</a> <span class="text-muted">wiselyman</span> <a class="tag" taget="_blank" href="/search/spring+boot/1.htm">spring boot</a> <div>    Spring Boot 1.2.5已在7月2日发布,现在可以从spring的maven库和maven中心库下载。   这个版本是一个维护的发布版,主要是一些修复以及将Spring的依赖提升至4.1.7(包含重要的安全修复)。   官方建议所有的Spring Boot用户升级这个版本。   项目首页 | 源</div> </li> </ul> </div> </div> </div> <div> <div class="container"> <div class="indexes"> <strong>按字母分类:</strong> <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a> </div> </div> </div> <footer id="footer" class="mb30 mt30"> <div class="container"> <div class="footBglm"> <a target="_blank" href="/">首页</a> - <a target="_blank" href="/custom/about.htm">关于我们</a> - <a target="_blank" href="/search/Java/1.htm">站内搜索</a> - <a target="_blank" href="/sitemap.txt">Sitemap</a> - <a target="_blank" href="/custom/delete.htm">侵权投诉</a> </div> <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved. <!-- <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>--> </div> </div> </footer> <!-- 代码高亮 --> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script> <link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/> <script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script> </body> </html>