ID English原文 中文翻译 最近翻译记录 状态 操作
0#翻译
Appendix F: Built-in Template Tags and Filters
----------------------------------------------
附录F 内建的模板标签和过滤器
----------------------------------------------
2632天前 Nikki 翻译
1#翻译
Chapter 4 lists a number of the most useful built-in template tags and filters.
However, Django ships with many more built-in tags and filters. This appendix lists
the ones that were included at the time this book was written, but new tags get
added fairly regularly.
第四章列出了许多的常用内建模板标签和过滤器。然而,Django自带了更多的内建模板标签及过滤器。
这章附录列出了截止到编写本书时,Django所包含的各个内建模板标签和过滤器,但是,新的标签是会被定期地加入的。
2632天前 Trix 翻译
2#翻译
The best reference to all the available tags and filters is directly in your admin
interface. Djangos admin interface includes a complete reference of all tags and
filters available for a given site. To see it, go to your admin interface and click
the Documentation link at the upper right of the page.
对于提供的标签和过滤器,最好的参考就是直接进入你的管理界面。Django的管理界面包含了一份针对当前站点的所有标签和过滤器的完整参考。想看到它的话,进入你的管理界面,单击右上角的Documentation(文档)链接。
2632天前 翻译
3#翻译
The tags and filters sections of the built-in documentation describe all the
built-in tags (in fact, the tag and filter references in this appendix come
directly from those pages) as well as any custom tag libraries available.
内建文档中的“标签和过滤器”小节阐述了所有内建标签(事实上,本附录中的标签和过滤器参考都直接来自那里)和所有可用的定制标签库。
2632天前 翻译
4#翻译
For those without an admin site available, reference for the stock tags and filters
follows. Because Django is highly customizable, the reference in your admin site
should be considered the final word on the available tags and filters and what they
do.
考虑到那些没有管理站点可用的人们,这里提供了常用的标签和过滤器的参考。由于Django是可高度定制的,管理界面中的那些可用的标签和过滤器的参考可认为是最可信的。
5663天前 翻译
5#翻译
Built-in Tag Reference
``````````````````````
内建标签参考
````````````
5663天前 翻译
6#翻译
block
'''''
block
'''''
5703天前 翻译
7#翻译
Defines a block that can be overridden by child templates. See the section on
template inheritance in Chapter 4 for more information.
定义一个能被子模板覆盖的区块。参见第四章“模板继承”一节查看更多信息。
5663天前 翻译
8#翻译
comment
'''''''
comment
'''''''
2632天前 翻译
9#翻译
Ignores everything between ``{% comment %}`` and ``{% endcomment %}`` .
模板引擎会忽略掉 ``{% comment %}`` 和 ``{% endcomment %}`` 之间的所有内容。
5663天前 翻译
10#翻译
cycle
'''''
cycle
'''''
5663天前 翻译
11#翻译
Cycles among the given strings each time this tag is encountered.
轮流使用标签给出的字符串列表中的值。
5856天前 翻译
12#翻译
Within a loop, it cycles among the given strings each time through the loop:
在一个循环内,轮流使用给定的字符串列表元素:
2632天前 翻译
15#翻译
Outside of a loop, give the values a unique name the first time you call it, and
then use that name each successive time through:
在循环外,在你第一次调用时,给这些字符串值定义一个不重复的名字,以后每次只需使用这个名字就行了:
2632天前 翻译
18#翻译
You can use any number of values, separated by commas. Make sure not to put spaces
between the values only commas.
你可以使用任意数量的用逗号分隔的值。注意不要在值与值之间有空格,只是一个逗号。
5856天前 翻译
19#翻译
debug
'''''
debug
'''''
5663天前 翻译
20#翻译
Outputs a whole load of debugging information, including the current context and
imported modules.
输出完整的调试信息,包括当前的上下文及导入的模块信息。
2632天前 翻译
21#翻译
extends
'''''''
extends
'''''''
5663天前 翻译
22#翻译
Signals that this template extends a parent template.
标记当前模板扩展一个父模板。
5856天前 翻译
23#翻译
This tag can be used in two ways:
这个标签有两种用法:
5856天前 翻译
24#翻译
*   ``{% extends "base.html" %}`` (with quotes) uses the literal value
    ``"base.html"`` as the name of the parent template to extend.
*   ``{% extends "base.html" %}`` (带引号) 直接使用要扩展的父模板的名字 ``"base.html"`` 。
5663天前 翻译
25#翻译
*   ``{% extends variable %}`` uses the value of ``variable`` . If the variable
    evaluates to a string, Django will use that string as the name of the parent
    template. If the variable evaluates to a ``Template`` object, Django will use
    that object as the parent template.
*   ``{% extends variable %}`` 用变量 ``variable`` 的值来指定父模板。如果变量是一个字符串,Django会把字符串的值当作父模板的文件名。如果变量是一个 ``Template`` 对象,Django会把这个对象当作父模板。
5663天前 翻译
26#翻译
See Chapter 4 for many usage examples.
参看第四章更多应用实例。
5703天前 翻译
27#翻译
filter
''''''
filter
''''''
5663天前 翻译
28#翻译
Filters the contents of the variable through variable filters.
通过可变过滤器过滤变量的内容。
5703天前 Zarya 翻译
29#翻译
Filters can also be piped through each other, and they can have arguments just like
in variable syntax.
过滤器也可以相互传输,它们也可以有参数,就像变量的语法一样。
5703天前 Regina 翻译
30#翻译
Heres a sample usage:
看这个用法实例:
5663天前 翻译
33#翻译
firstof
'''''''
firstof
'''''''
5663天前 翻译
34#翻译
Outputs the first variable passed that is not ``False`` . Outputs nothing if all
the passed variables are ``False`` .
输出传入的第一个不是 ``False`` 的变量,如果被传递变量都为 ``False`` ,则什么也不输出。
5662天前 Denver 翻译
35#翻译
Heres a sample usage:
看这个用法实例:
5663天前 翻译
38#翻译
This is equivalent to the following:
这等同于如下内容:
5703天前 Travon 翻译
41#翻译
for
'''
for
'''
5663天前 翻译
42#翻译
Loops over each item in an array. For example, to display a list of athletes given
``athlete_list`` :
轮询数组中的每一元素。例如显示一个指定的运动员的序列 ``athlete_list`` :
5663天前 翻译
45#翻译
You can also loop over a list in reverse by using ``{% for obj in list reversed
%}`` .
你也可以逆向遍历一个列表 ``{% for obj in list reversed %}`` 。
5663天前 翻译
46#翻译
The ``for`` loop sets a number of variables available within the loop (see Table
F-1).
``for`` 循环设置了许多循环中可用的变量(见表F-1)。
5663天前 Coralee 翻译
47#翻译
.. table:: Table F-1. Variables Available Inside {% for %}Loops

    +-----------------------+---------------------------------------------------------+
    |Variable               |Description                                              |
    +=======================+=========================================================+
    |``forloop.counter``    |The current iteration of the loop (1-indexed).           |
    +-----------------------+---------------------------------------------------------+
    |``forloop.counter0``   |The current iteration of the loop (0-indexed).           |
    +-----------------------+---------------------------------------------------------+
    |``forloop.revcounter`` |The number of iterations from the end of the loop        |
    |                       |(1-indexed).                                             |
    +-----------------------+---------------------------------------------------------+
    |``forloop.revcounter0``|The number of iterations from the end of the loop        |
    |                       |(0-indexed).                                             |
    +-----------------------+---------------------------------------------------------+
    |``forloop.first``      |``True`` if this is the first time through the loop.     |
    +-----------------------+---------------------------------------------------------+
    |``forloop.last``       |``True`` if this is the last time through the loop.      |
    +-----------------------+---------------------------------------------------------+
    |``forloop.parentloop`` |For nested loops, this is the loop above the current one.|
    +-----------------------+---------------------------------------------------------+
    
.. table:: 表F-1. {% for %}循环中的可用变量

    +-----------------------+---------------------------------------------------------+
    |变量名                 |描述                                                     |
    +=======================+=========================================================+
    |``forloop.counter``    |当前循环次数(索引最小为1)。                            |
    +-----------------------+---------------------------------------------------------+
    |``forloop.counter0``   |当前循环次数 (索引最小为0)。                             |
    +-----------------------+---------------------------------------------------------+
    |``forloop.revcounter`` |剩余循环次数 (索引最小为1)。                             |
    +-----------------------+---------------------------------------------------------+
    |``forloop.revcounter0``|剩余循环次数 (索引最小为0)。                             |
    +-----------------------+---------------------------------------------------------+
    |``forloop.first``      |第一次循环时为 ``True`` 。                               |
    +-----------------------+---------------------------------------------------------+
    |``forloop.last``       |最后一次循环时为 ``True`` 。                             |
    +-----------------------+---------------------------------------------------------+
    |``forloop.parentloop`` |用于嵌套循环,表示当前循环外层的循环。                   |
    +-----------------------+---------------------------------------------------------+
    

5663天前 Honey 翻译
50#翻译
if
''
if
''
5703天前 Hayle 翻译
51#翻译
The ``{% if %}`` tag evaluates a variable, and if that variable is true (i.e., it
exists, is not empty, and is not a false Boolean value), the contents of the block
are output:
``{% if %}`` 标签测试一个变量,若变量为真(即其存在、非空,且不是一个为假的布尔值),区块中的内容就会被输出:
5663天前 翻译
54#翻译
If ``athlete_list`` is not empty, the number of athletes will be displayed by the
``{{ athlete_list|length }}`` variable.
若 ``athlete_list`` 非空,变量 ``{{ athlete_list|length }}`` 就会显示运动员的数量。
5663天前 翻译
55#翻译
As you can see, the ``if`` tag can take an optional ``{% else %}`` clause that will
be displayed if the test fails.
正如你所见, ``if`` 标签有可选的 ``{% else %}`` 从句,若条件不成立则显示该从句。
5663天前 翻译
56#翻译
``if`` tags may use ``and`` , ``or`` , or ``not`` to test a number of variables or
to negate a given variable:
``if`` 语句可使用 ``and`` 、 ``or`` 和 ``not`` 来测试变量或者对给定的变量取反:
5663天前 翻译
59#翻译
``if`` tags dont allow ``and`` and ``or`` clauses within the same tag, because the
order of logic would be ambiguous. For example, this is invalid:
不允许 ``and`` 和 ``or`` 同时出现在一个 ``if`` 语句中,因为这样会有逻辑上的问题。例如这样是有语病的:
5663天前 翻译
62#翻译
If you need to combine ``and`` and ``or`` to do advanced logic, just use nested
``if`` tags, for example:
如果你需要同时使用 ``and`` 和 ``or`` 来实现较高级的逻辑,可以用嵌套的 ``if`` 标签来实现。例如:
5663天前 翻译
65#翻译
Multiple uses of the same logical operator are fine, as long as you use the same
operator. For example, this is valid:
重复使用同一逻辑符是可以的。例如这样是正确的:
5703天前 翻译
68#翻译
ifchanged
'''''''''
ifchanged
'''''''''
5703天前 翻译
69#翻译
Checks if a value has changed from the last iteration of a loop.
检查循环中一个值从最近一次重复其是否改变。
5703天前 翻译
70#翻译
The ``ifchanged`` block tag is used within a loop. It has two possible uses:
``ifchanged`` 语句块用于循环中,其作用有两个:
5663天前 翻译
71#翻译
    It checks its own rendered contents against its previous state and only
    displays the content if it has changed. For example, this displays a list of
    days, only displaying the month if it changes:
    它会把要渲染的内容与前一次作比较,发生变化时才显示它。例如,下面要显示一个日期列表,只有月份改变时才会显示它:
5663天前 翻译
74#翻译
    If given a variable, it checks whether that variable has changed:
    如果给的是一个变量,就会检查它是否发生改变。
5663天前 翻译
77#翻译
    The preceding shows the date every time it changes, but it only shows the hour
    if both the hour and the date have changed.
    前面那个例子中日期每次发生变化时就会显示出来,但只有小时和日期都发生变化时才会显示小时。
5663天前 翻译
78#翻译
ifequal
'''''''
ifequal
'''''''
5663天前 翻译
79#翻译
Outputs the contents of the block if the two arguments equal each other.
如果两个参数相等,就输出该区块的内容。
5663天前 翻译
80#翻译
Heres an example:
举个例子:
5765天前 翻译
83#翻译
As in the ``{% if %}`` tag, an ``{% else %}`` clause is optional.
正如 ``{% if %}`` 标签一样, ``{% else %}`` 语句是可选的。
5663天前 翻译
84#翻译
The arguments can be hard-coded strings, so the following is valid:
参数也可以是硬编码的字符串,所以下面这种写法是正确的:
5663天前 翻译
87#翻译
It is only possible to compare an argument to template variables or strings. You
cannot check for equality with Python objects such as ``True`` or ``False`` . If
you need to test if something is true or false, use the ``if`` tag instead.
可以用来比较的参数只限于模板变量或者字符串(实际上整数和小数也是可以的——译注),你不能检查诸如 ``True`` or ``False`` 等Python对象是否相等。如果你需要测试某值的真假,可以用 ``if`` 标签。
5663天前 翻译
88#翻译
ifnotequal
''''''''''
ifnotequal
''''''''''
5663天前 翻译
89#翻译
Just like ``ifequal`` , except it tests that the two arguments are *not* equal.
和 ``ifequal`` 类似,不过它是用来测试两个参数是 *不* 相等的。
5663天前 翻译
90#翻译
include
'''''''
include
'''''''
5663天前 翻译
91#翻译
Loads a template and renders it with the current context. This is a way of
including other templates within a template.
加载一个模板,并用当前上下文对它进行渲染,这是在一个模板中包含其他模板的一种方法。
5662天前 翻译
92#翻译
The template name can be either a variable or a hard-coded (quoted) string, in
either single or double quotes.
模板名可以是一个变量或者是一个硬编码(引号引起来的)的字符串,引号可以是单引号或者双引号。
5662天前 翻译
93#翻译
This example includes the contents of the template ``"foo/bar.html"`` :
这个例子包含了 ``"foo/bar.html"`` 模板的内容:
5662天前 翻译
96#翻译
This example includes the contents of the template whose name is contained in the
variable ``template_name`` :
这个例子包含了名字由变量 ``template_name`` 指定的模板的内容:
5662天前 翻译
99#翻译
load
''''
load
''''
5662天前 翻译
100#翻译
Loads a custom template library. See Chapter 10 for information about custom
template libraries.
读入一个自定义的模板库。第十章里有关于自定义模板的相关信息资料
5686天前 翻译
101#翻译
now
'''
now
'''
5662天前 翻译
102#翻译
Displays the date, formatted according to the given string.
根据给定的格式字符串显示当前日期。
5662天前 翻译
103#翻译
This tag was inspired by, and uses the same format as, a PHPs ``date()`` function
(`http://php.net/date`_). Djangos version, however, has some custom extensions.
这个标签来源于PHP中的 ``date()`` 函数( `http://php.net/date`_ ),并使用与其相同的格式语法,但是Django对其做了扩展。
5662天前 翻译
104#翻译
Table F-2 shows the available format strings.
表F-2显示了可用的格式字符串。
5662天前 翻译
105#翻译
.. table:: Table F-2. Available Date Format Strings

    +---------+--------------------------------------------------------+--------------+
    |Format   |Description                                             |Example Output|
    |Character|                                                        |              |
    +=========+========================================================+==============+
    |a        |``'a.m.'`` or ``'p.m.'`` . (Note that this is slightly  |``'a.m.'``    |
    |         |different from PHPs output, because this includes       |              |
    |         |periods to match Associated Press style.)               |              |
    +---------+--------------------------------------------------------+--------------+
    |A        |``'AM'`` or ``'PM'`` .                                  |``'AM'``      |
    +---------+--------------------------------------------------------+--------------+
    |b        |Month, textual, three letters, lowercase                |``'jan'``     |
    +---------+--------------------------------------------------------+--------------+
    |d        |Day of the month, two digits with leading zeros.        |``'01'`` to   |
    |         |                                                        |``'31'``      |
    +---------+--------------------------------------------------------+--------------+
    |D        |Day of the week, textual, three letters.                |``'Fri'``     |
    +---------+--------------------------------------------------------+--------------+
    |f        |Time, in 12-hour hours and minutes, with minutes left   |``'1'`` ,     |
    |         |off if theyre zero.                                     |``'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'``      |
    +---------+--------------------------------------------------------+--------------+
    |j        |Day of the month without leading zeros.                 |``'1'`` to    |
    |         |                                                        |``'31'``      |
    +---------+--------------------------------------------------------+--------------+
    |l        |Day of the week, textual, long.                         |``'Friday'``  |
    +---------+--------------------------------------------------------+--------------+
    |L        |Boolean for whether its a leap year.                    |``True`` or   |
    |         |                                                        |``False``     |
    +---------+--------------------------------------------------------+--------------+
    |m        |Month, two digits with leading zeros.                   |``'01'`` to   |
    |         |                                                        |``'12'``      |
    +---------+--------------------------------------------------------+--------------+
    |M        |Month, textual, three letters.                          |``'Jan'``     |
    +---------+--------------------------------------------------------+--------------+
    |n        |Month without leading zeros.                            |``'1'`` to    |
    |         |                                                        |``'12'``      |
    +---------+--------------------------------------------------------+--------------+
    |N        |Month abbreviation in Associated Press style.           |``'Jan.'`` ,  |
    |         |                                                        |``'Feb.'`` ,  |
    |         |                                                        |``'March'`` , |
    |         |                                                        |``'May'``     |
    +---------+--------------------------------------------------------+--------------+
    |O        |Difference to Greenwich Mean Time in hours.             |``'+0200'``   |
    +---------+--------------------------------------------------------+--------------+
    |P        |Time, in 12-hour hours, minutes, and a.m./p.m., with    |``'1 a.m.'`` ,|
    |         |minutes left off if theyre zero and the special-case    |``'1:30       |
    |         |strings ``'midnight'`` and ``'noon'`` if appropriate.   |p.m.'`` ,     |
    |         |                                                        |``'midnight'``|
    |         |                                                        |, ``'noon'`` ,|
    |         |                                                        |``'12:30      |
    |         |                                                        |p.m.'``       |
    +---------+--------------------------------------------------------+--------------+
    |r        |RFC 822 formatted date.                                 |``'Thu, 21 Dec|
    |         |                                                        |2000 16:01:07 |
    |         |                                                        |+0200'``      |
    +---------+--------------------------------------------------------+--------------+
    |s        |Seconds, two digits with leading zeros.                 |``'00'`` to   |
    |         |                                                        |``'59'``      |
    +---------+--------------------------------------------------------+--------------+
    |S        |English ordinal suffix for day of the month, two        |``'st'`` ,    |
    |         |characters.                                             |``'nd'`` ,    |
    |         |                                                        |``'rd'`` or   |
    |         |                                                        |``'th'``      |
    +---------+--------------------------------------------------------+--------------+
    |t        |Number of days in the given month.                      |``28`` to     |
    |         |                                                        |``31``        |
    +---------+--------------------------------------------------------+--------------+
    |T        |Time zone of this machine.                              |``'EST'`` ,   |
    |         |                                                        |``'MDT'``     |
    +---------+--------------------------------------------------------+--------------+
    |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    |``1`` , ``23``|
    |         |Monday.                                                 |              |
    +---------+--------------------------------------------------------+--------------+
    |y        |Year, two digits.                                       |``'99'``      |
    +---------+--------------------------------------------------------+--------------+
    |Y        |Year, four digits.                                      |``'1999'``    |
    +---------+--------------------------------------------------------+--------------+
    |z        |Day of the year.                                        |``0`` to      |
    |         |                                                        |``365``       |
    +---------+--------------------------------------------------------+--------------+
    |Z        |Time zone offset in seconds. The offset for time zones  |``-43200`` to |
    |         |west of UTC is always negative, and for those east of   |``43200``     |
    |         |UTC it is always positive.                              |              |
    +---------+--------------------------------------------------------+--------------+
    
.. table:: 表F-2. 可用的日期格式字符串

    +---------+--------------------------------------------------------+--------------+
    |格式字符 |描述                                                    |示例输出      |
    |串       |                                                        |              |
    +=========+========================================================+==============+
    |a        |``'a.m.'`` 或者 ``'p.m.'`` 。(这与PHP中的输出略有不同,|``'a.m.'``    |
    |         |因为为了匹配美联社风格,它包含了句点。                  |              |
    +---------+--------------------------------------------------------+--------------+
    |A        |``'AM'`` 或者 ``'PM'`` 。                               |``'AM'``      |
    +---------+--------------------------------------------------------+--------------+
    |b        |月份,文字式的,三个字母,小写。                        |``'jan'``     |
    +---------+--------------------------------------------------------+--------------+
    |d        |一月的第几天,两位数字,带前导零。                      |``'01'`` 到   |
    |         |                                                        |``'31'``      |
    +---------+--------------------------------------------------------+--------------+
    |D        |一周的第几天,文字式的,三个字母。                      |``'Fri'``     |
    +---------+--------------------------------------------------------+--------------+
    |f        |时间,12小时制的小时和分钟数,如果分钟数为零则不显示。  |``'1'`` ,     |
    |         |                                                        |``'1:30'``    |
    +---------+--------------------------------------------------------+--------------+
    |F        |月份,文字式的,全名。                                  |``'January'`` |
    +---------+--------------------------------------------------------+--------------+
    |g        |小时,12小时制,没有前导零。                            |``'1'`` 到    |
    |         |                                                        |``'12'``      |
    +---------+--------------------------------------------------------+--------------+
    |G        |小时,24小时制,没有前导零。                            |``'0'`` 到    |
    |         |                                                        |``'23'``      |
    +---------+--------------------------------------------------------+--------------+
    |h        |小时,12小时制。                                        |``'01'`` 到   |
    |         |                                                        |``'12'``      |
    +---------+--------------------------------------------------------+--------------+
    |H        |小时,24小时制。                                        |``'00'`` 到   |
    |         |                                                        |``'23'``      |
    +---------+--------------------------------------------------------+--------------+
    |i        |分钟。                                                  |``'00'`` 到   |
    |         |                                                        |``'59'``      |
    +---------+--------------------------------------------------------+--------------+
    |j        |一月的第几天,不带前导零。                              |``'1'`` 到    |
    |         |                                                        |``'31'``      |
    +---------+--------------------------------------------------------+--------------+
    |l        |一周的第几天,文字式的,全名。                          |``'Friday'``  |
    +---------+--------------------------------------------------------+--------------+
    |L        |是否为闰年的布尔值。                                    |``True`` 到   |
    |         |                                                        |``False``     |
    +---------+--------------------------------------------------------+--------------+
    |m        |月份,两位数字,带前导零。                              |``'01'`` 到   |
    |         |                                                        |``'12'``      |
    +---------+--------------------------------------------------------+--------------+
    |M        |月份,文字式的,三个字母。                              |``'Jan'``     |
    +---------+--------------------------------------------------------+--------------+
    |n        |月份,没有前导零。                                      |``'1'`` 到    |
    |         |                                                        |``'12'``      |
    +---------+--------------------------------------------------------+--------------+
    |N        |美联社风格的月份缩写。                                  |``'Jan.'`` ,  |
    |         |                                                        |``'Feb.'`` ,  |
    |         |                                                        |``'March'`` , |
    |         |                                                        |``'May'``     |
    +---------+--------------------------------------------------------+--------------+
    |O        |与格林威治标准时间的时间差(以小时计)。                |``'+0200'``   |
    +---------+--------------------------------------------------------+--------------+
    |P        |时间,12小时制的小时分钟数以及a.m./p.m.,分钟数如果为零 |``'1 a.m.'`` ,|
    |         |则不显示,用字符串表示特殊时间点,如 ``'midnight'`` 和  |``'1:30       |
    |         |``'noon'`` 。                                           |p.m.'`` ,     |
    |         |                                                        |``'midnight'``|
    |         |                                                        |, ``'noon'`` ,|
    |         |                                                        |``'12:30      |
    |         |                                                        |p.m.'``       |
    +---------+--------------------------------------------------------+--------------+
    |r        |RFC 822 格式的日期。                                    |``'Thu, 21 Dec|
    |         |                                                        |2000 16:01:07 |
    |         |                                                        |+0200'``      |
    +---------+--------------------------------------------------------+--------------+
    |s        |秒数,两位数字,带前导零。                              |``'00'`` 到   |
    |         |                                                        |``'59'``      |
    +---------+--------------------------------------------------------+--------------+
    |S        |英语序数后缀,用于表示一个月的第几天,两个字母。        |``'st'`` ,    |
    |         |                                                        |``'nd'`` ,    |
    |         |                                                        |``'rd'`` 到   |
    |         |                                                        |``'th'``      |
    +---------+--------------------------------------------------------+--------------+
    |t        |指定月份的天数。                                        |``28`` 到     |
    |         |                                                        |``31``        |
    +---------+--------------------------------------------------------+--------------+
    |T        |本机的时区。                                            |``'EST'`` ,   |
    |         |                                                        |``'MDT'``     |
    +---------+--------------------------------------------------------+--------------+
    |w        |一周的第几天,数字,带前导零。                          |``'0'``       |
    |         |                                                        |(Sunday) 到   |
    |         |                                                        |``'6'``       |
    |         |                                                        |(Saturday)    |
    +---------+--------------------------------------------------------+--------------+
    |W        |ISO-8601 一年中的第几周,一周从星期一开始。             |``1`` , ``23``|
    +---------+--------------------------------------------------------+--------------+
    |y        |年份,两位数字。                                        |``'99'``      |
    +---------+--------------------------------------------------------+--------------+
    |Y        |年份,四位数字。                                        |``'1999'``    |
    +---------+--------------------------------------------------------+--------------+
    |z        |一年的第几天。                                          |``0`` 到      |
    |         |                                                        |``365``       |
    +---------+--------------------------------------------------------+--------------+
    |Z        |以秒计的时区偏移量,这个偏移量对于UTC西部时区总是负数, |``-43200`` 到 |
    |         |对于UTC东部时区总是正数。                               |``43200``     |
    +---------+--------------------------------------------------------+--------------+
    

5662天前 markus 翻译
108#翻译
Heres an example:
看这个例子:
5662天前 翻译
111#翻译
Note that you can backslash-escape a format string if you want to use the raw
value. In this example, f is backslash-escaped, because otherwise f is a format
string that displays the time. The o doesnt need to be escaped, because its not a
format character:
记住,如果你想用一个字符串的原始值的话,你可以用反斜线进行转义。在这个例子中,f被用反斜线转义了,如果不转义的话f就是显示时间的格式字符串。o不用转义,因为它本来就不是一个格式字母。
5662天前 翻译
114#翻译
This would display as It is the 4th of September.
这样就会显示成“It is the 4th of September”。
5662天前 翻译
115#翻译
regroup
'''''''
regroup
'''''''
5662天前 翻译
116#翻译
Regroups a list of alike objects by a common attribute.
把一列相似的对象根据某一个共有的属性重新分组。
5662天前 翻译
117#翻译
This complex tag is best illustrated by use of an example. Say that ``people`` is a
list of ``Person`` objects that have ``first_name`` , ``last_name`` , and
``gender`` attributes, and youd like to display a list that looks like this:
要解释清这个复杂的标签,最好来举个例子。比如, ``people`` 是包含 ``Person`` 对象的一个列表, 这个对象拥有 ``first_name`` 、 ``last_name`` 和 ``gender`` 属性,你想这样显示这个列表:
5662天前 翻译
120#翻译
The following snippet of template code would accomplish this dubious task:
下面这段模板代码就可以完成这个看起来很复杂的任务:
5662天前 翻译
123#翻译
As you can see, ``{% regroup %}`` populates a variable with a list of objects with
``grouper`` and ``list`` attributes. ``grouper`` contains the item that was grouped
by; ``list`` contains the list of objects that share that ``grouper`` . In this
case, ``grouper`` would be ``Male`` , ``Female`` , and ``Unknown`` , and ``list``
is the list of people with those genders.
如你所见, ``{% regroup %}`` 构造了一个列表变量,列表中的每个对象都有 ``grouper`` 和 ``list`` 属性。 ``grouper`` 包含分组所依据的属性, ``list`` 包含一系列拥有共同的 ``grouper`` 属性的对象。这样 ``grouper`` 就会是 ``Male`` 、 ``Female`` 和 ``Unknown`` , ``list`` 就是属于这几种性别的人们。
5662天前 翻译
124#翻译
Note that ``{% regroup %}`` does not work when the list to be grouped is not sorted
by the key you are grouping by! This means that if your list of people was not
sorted by gender, youd need to make sure it is sorted before using it, that is:
记住,如果被分组的列表不是按照某一列排好序的话,你就不能用 ``{% regroup %}`` 在这一列上进行重新分组!就是说如果人的列表不是按照性别排好序的话,在用它之前就要先对它排序,即:
5662天前 翻译
127#翻译
spaceless
'''''''''
spaceless
'''''''''
5662天前 翻译
128#翻译
Removes whitespace between HTML tags. This includes tab characters and newlines.
去除HTML标签之间的空白符号,包括制表符和换行符。
5662天前 翻译
129#翻译
Heres an example:
例如:
5686天前 翻译
132#翻译
This example would return this HTML:
返回结果如下:
5686天前 翻译
135#翻译
Only space between *tags* is removed not space between tags and text. In this
example, the space around ``Hello`` wont be stripped:
仅仅 *标签* 之间的空白符被删掉,标签和文本之间的空白符是不会被处理的。在下面这个例子中, ``Hello`` 两边的空白符是不会被截掉的:
5662天前 翻译
138#翻译
ssi
'''
ssi
'''
5662天前 翻译
139#翻译
Outputs the contents of a given file into the page.
把一个指定的文件的内容输出到页面上。
5662天前 翻译
140#翻译
Like a simple include tag, ``{% ssi %}`` includes the contents of another file
which must be specified using an absolute path in the current page:
像include标签一样, ``{% ssi %}`` 会包含另外一个文件的内容,这个文件必须以绝对路径指明:
5662天前 翻译
143#翻译
If the optional parsed parameter is given, the contents of the included file are
evaluated as template code, within the current context:
如果指定了可选的parsed参数的话,包含进来的文件的内容会被当作模板代码,并用当前的上下文来渲染:
5662天前 翻译
146#翻译
Note that if you use ``{% ssi %}`` , youll need to define ALLOWED_INCLUDE_ROOTS in
your Django settings, as a security measure.
注意,如果你要使用 ``{% ssi %}`` 的话,为了安全起见,你必须在Django配置文件中定义ALLOWED_INCLUDE_ROOTS。
5662天前 翻译
147#翻译
Most of the time ``{% include %}`` works better than ``{% ssi %}`` ; ``{% ssi %}``
exists mostly for backward compatibility.
大多数情况下 ``{% include %}`` 比 ``{% ssi %}`` 更好用, ``{% ssi %}`` 的存在通常是为了向后兼容。
5662天前 翻译
148#翻译
templatetag
'''''''''''
templatetag
'''''''''''
5662天前 翻译
149#翻译
Outputs one of the syntax characters used to compose template tags.
输出组成模板标签的语法字符。
5662天前 翻译
150#翻译
Since the template system has no concept of escaping, to display one of the bits
used in template tags, you must use the ``{% templatetag %}`` tag.
模板系统没有转义的概念,所以要显示一个组成模板标签的字符的话,你必须使用 ``{% templatetag %}`` 标签。
5662天前 翻译
151#翻译
The argument tells which template bit to output (see Table F-3).
参数用来标明要显示的字符(参见表F-3)。
5662天前 翻译
152#翻译
.. table:: Table F-3. Valid Arguments to templatetag

    +-----------------+------+
    |Argument         |Output|
    +=================+======+
    |``openblock``    |``{%``|
    +-----------------+------+
    |``closeblock``   |``%}``|
    +-----------------+------+
    |``openvariable`` |``{{``|
    +-----------------+------+
    |``closevariable``|``}}``|
    +-----------------+------+
    |``openbrace``    |``{`` |
    +-----------------+------+
    |``closebrace``   |``}`` |
    +-----------------+------+
    |``opencomment``  |``{#``|
    +-----------------+------+
    |``closecomment`` |``#}``|
    +-----------------+------+
    
.. table:: 表F-3. templatetag的有效参数

    +-----------------+------+
    |参数             |输出  |
    +=================+======+
    |``openblock``    |``{%``|
    +-----------------+------+
    |``closeblock``   |``%}``|
    +-----------------+------+
    |``openvariable`` |``{{``|
    +-----------------+------+
    |``closevariable``|``}}``|
    +-----------------+------+
    |``openbrace``    |``{`` |
    +-----------------+------+
    |``closebrace``   |``}`` |
    +-----------------+------+
    |``opencomment``  |``{#``|
    +-----------------+------+
    |``closecomment`` |``#}``|
    +-----------------+------+
    

5662天前 翻译
155#翻译
url
'''
url
'''
5662天前 翻译
156#翻译
Returns an absolute URL (i.e., a URL without the domain name) matching a given view
function and optional parameters. This is a way to output links without violating
the DRY principle by having to hard-code URLs in your templates:
根据所给视图函数和可选参数,返回一个绝对的URL(就是不带域名的URL)。由于没有在模板中对URL进行硬编码,所以这种输出链接的方法没有违反DRY原则。
5662天前 翻译
159#翻译
The first argument is a path to a view function in the format
``package.package.module.function`` . Additional arguments are optional and should
be comma-separated values that will be used as positional and keyword arguments in
the URL. All arguments required by the URLconf should be present.
第一个变量是按package.package.module.function形式给出的指向一个view函数的路径。那些可选的、用逗号分隔的附加参数被用做URL中的位置和关键词变量。所有URLconf需要的参数都应该是存在的。
5600天前 翻译
160#翻译
For example, suppose you have a view, ``app_name.client`` , whose URLconf takes a
client ID. The URLconf line might look like this:
例如,假设你有一个view,app_name.client,它的URLconf包含一个client ID参数。URLconf对应行可能看起来像这样:
5600天前 翻译
163#翻译
If this applications URLconf is included into the projects URLconf under a path
such as this:
如果这个应用的URLconf像下面一样被包含在项目的URLconf里:
5600天前 翻译
166#翻译
then, in a template, you can create a link to this view like this:
那么,在模板中,你可以像这样创建一个指向那个view的link连接:
5600天前 翻译
169#翻译
The template tag will output the string ``/clients/client/123/`` .
模板标签将输出字符串/clients/client/123/
5600天前 翻译
170#翻译
widthratio
''''''''''
widthratio,寬度的比率
5452天前 翻译
171#翻译
For creating bar charts and such, this tag calculates the ratio of a given value to
a maximum value, and then applies that ratio to a constant.
為了畫出長條圖,這個標籤計算一個給定值相對於最大值的比率,然後將這個比率給定一個常數
5452天前 翻译
172#翻译
Heres an example:
一些实例:
5360天前 翻译
175#翻译
If ``this_value`` is 175 and ``max_value`` is 200, the image in the preceding
example will be 88 pixels wide (because 175/200 = .875; .875 * 100 = 87.5, which is
rounded up to 88).
如果“this_value”是175, "max_value"是200,那么前一个例子的图像将会是 88像素宽(因为175/200 = .875; .875 * 100 = 87.5,将会被四舍五入到88)
4323天前 翻译
176#翻译
Built-in Filter Reference
`````````````````````````
Built-in Filter Reference
4323天前 翻译
177#翻译
add
'''
add
,,,
4323天前 翻译
178#翻译
Example:
例如:
5549天前 翻译
181#翻译
Adds the argument to the value.
参数与被处理数据相加的结果.
5200天前 翻译
182#翻译
addslashes
''''''''''
addslashes
''''''''''

4323天前 翻译
183#翻译
Example:
例如:
5549天前 翻译
186#翻译
Adds backslashes before single and double quotes. This is useful for passing
strings to JavaScript, for example.
给敏感字符添加斜线(转义). 举例,要将一个字符串传递给 JavaScript 时.
5200天前 翻译
187#翻译
capfirst
''''''''
capfirst
''''''''

4323天前 翻译
188#翻译
Example:
例如:
5549天前 翻译
191#翻译
Capitalizes the first character of the string.
将字符串的首字母大写
5480天前 翻译
192#翻译
center
''''''
翻译 5932天前 翻译
193#翻译
Example:
例如:
5549天前 翻译
196#翻译
Centers the string in a field of a given width.
在一个给定的长度让字符串居中
5360天前 翻译
197#翻译
cut
'''
翻译 5932天前 翻译
198#翻译
Example:
例如:
5549天前 翻译
201#翻译
Removes all values of the argument from the given string.
把给定字符串中包含的所有参数值删除掉。
5360天前 翻译
202#翻译
date
''''
翻译 5932天前 翻译
203#翻译
Example:
例如
4323天前 翻译
206#翻译
Formats a date according to the given format (same as the ``now`` tag).
把一个date类型按照给定的格式输出(与"now"标签用法一样)。
5360天前 翻译
207#翻译
default
'''''''
翻译 5932天前 翻译
208#翻译
Example:
例如:
5549天前 翻译
211#翻译
If the value is unavailable, use the given default.
如果变量不存在,使用默认值
5549天前 翻译
212#翻译
default_if_none
'''''''''''''''
翻译 5932天前 翻译
213#翻译
Example:
例如:
5549天前 翻译
216#翻译
If the value is ``None`` , use the given default.
如果变量值为None,使用默认值
5549天前 翻译
217#翻译
dictsort
''''''''
翻译 5932天前 翻译
218#翻译
Example:
例如:
5549天前 翻译
221#翻译
Takes a list of dictionaries and returns that list sorted by the property given in
the argument.
接受一个字典列表,返回按给定参数的属性排序后的列表.
5200天前 翻译
222#翻译
dictsortreversed
''''''''''''''''
翻译 5932天前 翻译
223#翻译
Example:
例子:
5628天前 翻译
226#翻译
Takes a list of dictionaries and returns that list sorted in reverse order by the
property given in the argument.
接受一个字典列表,返回按给定参数的属性逆序排序后的列表
5200天前 翻译
227#翻译
divisibleby
'''''''''''
翻译 5932天前 翻译
228#翻译
Example:
翻译 5932天前 翻译
231#翻译
Returns ``True`` if the value is divisible by the argument.
如果值能够被给定的参数整除的话,返回“True”。
5360天前 翻译
232#翻译
escape
''''''
翻译 5932天前 翻译
233#翻译
Example:
例如:
5360天前 翻译
236#翻译
Escapes a strings HTML. Specifically, it makes these replacements:
按照以下的规则,转义一个HTML字符串:
5360天前 翻译
237#翻译
*   ``"&"`` to ``"&"``
翻译 5932天前 翻译
238#翻译
*   ``<`` to ``"&lt;"``
翻译 5932天前 翻译
239#翻译
*   ``>`` to ``"&gt;"``
翻译 5932天前 翻译
240#翻译
*   ``'"'`` (double quote) to ``'&quot;'``
翻译 5932天前 翻译
241#翻译
*   ``"'"`` (single quote) to ``'&#39;'``
翻译 5932天前 翻译
242#翻译
filesizeformat
''''''''''''''
翻译 5932天前 翻译
243#翻译
Example:
翻译 5932天前 翻译
246#翻译
Formats the value like a human-readable file size (i.e., ``'13 KB'`` , ``'4.1 MB'``
, ``'102 bytes'`` , etc).
将值格式化为 '可读性好的' 文件大小(比如 '13 KB', '4.1 MB', '102bytes' 等等).
5200天前 翻译
247#翻译
first
'''''
翻译 5932天前 翻译
248#翻译
Example:
翻译 5932天前 翻译
251#翻译
Returns the first item in a list.
返回列表中的第一个元素.
5200天前 翻译
252#翻译
fix_ampersands
''''''''''''''
翻译 5932天前 翻译
253#翻译
Example:
翻译 5932天前 翻译
256#翻译
Replaces ampersands with ``&amp;`` entities.
将 & 符号替换为 &amp; 实体
5200天前 翻译
257#翻译
floatformat
'''''''''''
翻译 5932天前 翻译
258#翻译
Examples:
翻译 5932天前 翻译
261#翻译
When used without an argument, rounds a floating-point number to one decimal place
but only if theres a decimal part to be displayed, for example:
将一个浮点数四舍五入到小数点后1位 -- 如果根本没有小数,小数部分不会显示.
4659天前 翻译
262#翻译
*   ``36.123`` gets converted to ``36.1`` .
翻译 5932天前 翻译
263#翻译
*   ``36.15`` gets converted to ``36.2`` .
翻译 5932天前 翻译
264#翻译
*   ``36`` gets converted to ``36`` .
翻译 5932天前 翻译
265#翻译
If used with a numeric integer argument, ``floatformat`` rounds a number to that
many decimal places:
如果使用同一个数字的整数参数,“floatformat”轮数,
许多小数位:
4659天前 翻译
266#翻译
*   ``36.1234`` with floatformat:3 gets converted to ``36.123`` .
翻译 5932天前 翻译
267#翻译
*   ``36`` with floatformat:4 gets converted to ``36.0000`` .
翻译 5932天前 翻译
268#翻译
If the argument passed to ``floatformat`` is negative, it will round a number to
that many decimal places but only if theres a decimal part to be displayed:
翻译 5932天前 翻译
269#翻译
*   ``36.1234`` with floatformat:-3 gets converted to ``36.123`` .
翻译 5932天前 翻译
270#翻译
*   ``36`` with floatformat:-4 gets converted to ``36`` .
翻译 5932天前 翻译
271#翻译
Using ``floatformat`` with no argument is equivalent to using ``floatformat`` with
an argument of ``-1`` .
翻译 5932天前 翻译
272#翻译
get_digit
'''''''''
翻译 5932天前 翻译
273#翻译
Example:
翻译 5932天前 翻译
276#翻译
Given a whole number, returns the requested digit of it, where 1 is the rightmost
digit, 2 is the second-to-rightmost digit, and so forth. It returns the original
value for invalid input (if the input or argument is not an integer, or if the
argument is less than 1). Otherwise, output is always an integer.
提供一个完整的数, 返回该数中被请求的数字,其中 1 是最右边的数, 2 是从右边数第二个数字等等. 若输入值非法(若输入或参数不是整数, 或者参数小于1)则返回其原始值. 否则输出就总是整数.
5200天前 翻译
277#翻译
join
''''
翻译 5932天前 翻译
278#翻译
Example:
例子:
5585天前 翻译
281#翻译
Joins a list with a string, like Pythons ``str.join(list)`` .
用一个字符串将一个列表连接起来,类似 Python 的 str.join(list).
5200天前 翻译
282#翻译
length
''''''
翻译 5932天前 翻译
283#翻译
Example:
例子:
5480天前 翻译
286#翻译
Returns the length of the value.
返回对象的长度
5480天前 翻译
287#翻译
length_is
'''''''''
翻译 5932天前 翻译
288#翻译
Example:
翻译 5932天前 翻译
291#翻译
Returns a Boolean of whether the values length is the argument.
若值的长度与参数相等,返回 True, 否则返回 False.
5200天前 翻译
292#翻译
linebreaks
''''''''''
翻译 5932天前 翻译
293#翻译
Example:
翻译 5932天前 翻译
296#翻译
Converts newlines into ``<p>`` and ``<br />`` tags.
把换行符转换成<p>和<br />标签。
5410天前 翻译
297#翻译
linebreaksbr
''''''''''''
翻译 5932天前 翻译
298#翻译
Example:
翻译 5932天前 翻译
301#翻译
Converts newlines into ``<br />`` tags.
把每个新行转换为"<br />"标签
5360天前 翻译
302#翻译
linenumbers
'''''''''''
翻译 5932天前 翻译
303#翻译
Example:
翻译 5932天前 翻译
306#翻译
Displays text with line numbers.
带行号显示文本
5200天前 翻译
307#翻译
ljust
'''''
翻译 5932天前 翻译
308#翻译
Example:
翻译 5932天前 翻译
311#翻译
Left-aligns the value in a field of a given width.
在给定宽度的域内将文本左对齐.
5200天前 翻译
312#翻译
lower
'''''
翻译 5932天前 翻译
313#翻译
Example:
翻译 5932天前 翻译
316#翻译
Converts a string into all lowercase.
把一个给定的字符串转换成小写。
5360天前 翻译
317#翻译
make_list
'''''''''
翻译 5932天前 翻译
318#翻译
Example:
翻译 5932天前 翻译
321#翻译
Returns the value turned into a list. For an integer, its a list of digits. For a
string, its a list of characters.
将值转化为一个列表.对一个整数,它是一个数字的列表.对一个字符串,这是一个字符的列表
5200天前 翻译
322#翻译
phone2numeric
'''''''''''''
翻译 5932天前 翻译
323#翻译
Example:
翻译 5932天前 翻译
326#翻译
Converts a phone number (possibly containing letters) to its numerical equivalent.
For example, ``'800-COLLECT'`` will be converted to ``'800-2655328'`` .
将一个电话号码(可能包含字母)转化等价的数字值.比如: '800-COLLECT' 将被转化为 '800-2655328'.
5200天前 翻译
327#翻译
The input doesnt have to be a valid phone number. This will happily convert any
string.
输入不一定非是一个合法号码. 它可以转化任意字符串.
5200天前 翻译
328#翻译
pluralize
'''''''''
翻译 5932天前 翻译
329#翻译
Example:
翻译 5932天前 翻译
332#翻译
Returns a plural suffix if the value is not 1. By default, this suffix is ``'s'`` .
如果值不是 1 的话返回 's' 用于 '1 vote' vs. '2 votes' 这种场合
5200天前 翻译
333#翻译
Example:
翻译 5932天前 翻译
336#翻译
For words that require a suffix other than ``'s'`` , you can provide an alternate
suffix as a parameter to the filter.
翻译 5932天前 翻译
337#翻译
Example:
翻译 5932天前 翻译
340#翻译
For words that dont pluralize by simple suffix, you can specify both a singular and
plural suffix, separated by a comma.
对于那些不能用单一后缀变成复数的词,你可以指定一个单数或复数后缀用逗号分隔。
4323天前 翻译
341#翻译
Example:
翻译 5932天前 翻译
344#翻译
pprint
''''''
翻译 5932天前 翻译
345#翻译
Example:
翻译 5932天前 翻译
348#翻译
A wrapper around Pythons built-in ``pprint.pprint`` for debugging, really.
pprint.pprint 和一个封装器-- 仅用于调试.
5200天前 翻译
349#翻译
random
''''''
翻译 5932天前 翻译
350#翻译
Example:
例如:
4323天前 翻译
353#翻译
Returns a random item from the list.
返回随机的从列表中返回一个元素
5200天前 翻译
354#翻译
removetags
''''''''''
removetags
''''''''''

4323天前 翻译
355#翻译
Example:
例如:
4323天前 翻译
358#翻译
Removes a space-separated list of [X]HTML tags from the output.
从输出中删除单空格分隔的 [X]HTML标签 列表
5200天前 翻译
359#翻译
rjust
'''''
rjust
'''''

4323天前 翻译
360#翻译
Example:
例如:
4323天前 翻译
363#翻译
Right-aligns the value in a field of a given width.
在给定宽度的域内将文本右对齐.
5200天前 翻译
364#翻译
slice
'''''
slice
'''''

4323天前 翻译
365#翻译
Example:
例如:
4323天前 翻译
368#翻译
Returns a slice of the list.
返回一个列表的片段
5200天前 翻译
369#翻译
Uses the same syntax as Pythons list slicing. See
`http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice`_ for
an introduction.
使用与 Python 的 list 相同的语法, 参阅 http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice 以了解更详细的信息.
5200天前 翻译
370#翻译
slugify
'''''''
slugify
'''''''

4323天前 翻译
371#翻译
Example:
例如:
4323天前 翻译
374#翻译
Converts to lowercase, removes nonword characters (alphanumerics and underscores),
and converts spaces to hyphens. It also strips leading and trailing whitespace.
转化为小写, 移去非单词字符(字母数字和下划线),将空白转化为连字符,去除前后空白.
5200天前 翻译
375#翻译
stringformat
''''''''''''
stringformat
''''''''''''

4323天前 翻译
376#翻译
Example:
Example:

4323天前 翻译
379#翻译
Formats the variable according to the argument, a string formatting specifier. This
specifier uses Python string-formatting syntax, with the exception that the leading
% is dropped.
根据给定参数(一个格式字符串)格式化一个变量, 这个格式字符串使用 Python 字符串格式化语法, 例外之处是 "%" 运算符被省略.
5200天前 翻译
380#翻译
See `http://docs.python.org/lib/typesseq-strings.html`_ for documentation of Python
string formatting.
参阅 http://docs.python.org/lib/typesseq-strings.html 以了解 Python 格式字符串
5200天前 翻译
381#翻译
striptags
'''''''''
striptags
'''''''''

4323天前 翻译
382#翻译
Example:
例如:
4323天前 翻译
385#翻译
Strips all [X]HTML tags.
过滤掉[X]HTML标签.
5200天前 翻译
386#翻译
time
''''
time
''''

4323天前 翻译
387#翻译
Example:
例如:
4323天前 翻译
390#翻译
Formats a time according to the given format (same as the ``now`` tag).
按指定的样式(样式定义同now标签)来格式化一个时间对象
5480天前 翻译
391#翻译
timesince
'''''''''
timesince
'''''''''

4323天前 翻译
392#翻译
Examples:
例如:
4323天前 翻译
395#翻译
Formats a date as the time since that date (e.g., 4 days, 6 hours).
格式化一个日期,这个日期是从给定日期到现在的天数和小时数(比如: "4 days, 6 hours").
5200天前 翻译
396#翻译
Takes an optional argument that is a variable containing the date to use as the
comparison point (without the argument, the comparison point is *now* ). For
example, if ``blog_date`` is a date instance representing midnight on 1 June 2006,
and ``comment_date`` is a date instance for 08:00 on 1 June 2006, then ``{{
comment_date|timesince:blog_date }}`` would return 8 hours.
接受一个可选的参数,该参数是一个包含比较日期的变量(该参数默认值是 now). 举例来说, 如果 blog_date 是一个日期实例表示 2006-06-01 午夜, 而 comment_date 是一个日期实例表示 2006-06-01 早上8点,那么 {{ comment_date|timesince:blog_date }} 将返回 "8 hours".
5200天前 翻译
397#翻译
timeuntil
'''''''''
timeuntil
'''''''''

4323天前 翻译
398#翻译
Examples:
例如:
4323天前 翻译
401#翻译
Similar to ``timesince`` , except that it measures the time from now until the
given date or datetime. For example, if today is 1 June 2006 and
``conference_date`` is a date instance holding 29 June 2006, then ``{{
conference_date|timeuntil }}`` will return 28 days.
类似 timesince, 只是它比较当前时间直到给定日期时间。举例来说,如果今天是 2006-06-01 而 conference_date 是 2006-06-29, 那么 {{ conference_date|timeuntil }} 将返回 "28 days".
5200天前 翻译
402#翻译
Takes an optional argument that is a variable containing the date to use as the
comparison point (instead of *now* ). If ``from_date`` contains 22 June 2006, then
``{{ conference_date|timeuntil:from_date }}`` will return 7 days.
接受一个可选的参数,该参数是一个包含比较日期的变量(该参数默认值是 now). 举例来说, 如果 from_date 是一个日期实例表示 2006-06-22, 那么 {{ conference_date|timeuntil:from_date }} 会返回 "7 days".
5200天前 翻译
403#翻译
title
'''''
title
'''''

4323天前 翻译
404#翻译
Example:
例如:
4323天前 翻译
407#翻译
Converts a string into title case.
按标题格式转化一个字符串
5200天前 翻译
408#翻译
truncatewords
'''''''''''''
truncatewords
'''''''''''''

4323天前 翻译
409#翻译
Example:
例如:
4323天前 翻译
412#翻译
Truncates a string after a certain number of words.
将一个字符串截短为指定数目的单词.
5200天前 翻译
413#翻译
truncatewords_html
''''''''''''''''''
truncatewords_html
''''''''''''''''''

4323天前 翻译
414#翻译
Example:
例如:
4323天前 翻译
417#翻译
Similar to ``truncatewords`` , except that it is aware of HTML tags. Any tags that
are opened in the string and not closed before the truncation point are closed
immediately after the truncation.
除了对HTML tags敏感外,和``truncatewords`` 相同。任何tags在断点关闭前都是开放的、没有关闭的,并且在(断点关闭)之后会关闭。
4323天前 翻译
418#翻译
This is less efficient than ``truncatewords`` , so it should be used only when it
is being passed HTML text.
这没有“truncatewords”有效,所以只有在传输HTML文本的时候才会用到它。
4323天前 翻译
419#翻译
unordered_list
''''''''''''''
unordered_list
''''''''''''''

4323天前 翻译
420#翻译
Example:
例如:
4323天前 翻译
423#翻译
Recursively takes a self-nested list and returns an HTML unordered list *without*
opening and closing <ul> tags.
递归的接受一个自嵌套的列表并返回一个HTML无序列表(此列表可不是pythob语义中的列表) -- 只是没有开始和结束的<ul>标签
5200天前 翻译
424#翻译
The list is assumed to be in the proper format. For example, if ``var`` contains
``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``
, then ``{{ var|unordered_list }}`` would return the following:
假定该列表是合适的格式. 举例来说, 如果 var 的值为 ['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]], 那么 {{ var|unordered_list }} 就会返回:
5200天前 翻译
427#翻译
upper
'''''
upper
'''''

4323天前 翻译
428#翻译
Example:
例子:
5703天前 翻译
431#翻译
Converts a string into all uppercase.
将一个字符串全部字母改为大写。
5703天前 翻译
432#翻译
urlencode
'''''''''
urlencode
'''''''''

4323天前 翻译
433#翻译
Example:
例子:
5703天前 翻译
436#翻译
Escapes a value for use in a URL.
转义该值以用于 URL.
5200天前 翻译
437#翻译
urlize
''''''
urlize
''''''

4323天前 翻译
438#翻译
Example:
例子:
5703天前 翻译
441#翻译
Converts URLs in plain text into clickable links.
将URLs由纯文本变为可点击的链接。
5703天前 翻译
442#翻译
urlizetrunc
'''''''''''
urlizetrunc
'''''''''''

4323天前 翻译
443#翻译
Example:
例子:
5703天前 翻译
446#翻译
Converts URLs into clickable links, truncating URLs to the given character limit.
将URLs变为可点击的链接,按给定字母限截短URLs。
5703天前 翻译
447#翻译
wordcount
'''''''''
wordcount
'''''''''
5703天前 翻译
448#翻译
Example:
例如:
5856天前 翻译
451#翻译
Returns the number of words.
返回单词数。
5856天前 翻译
452#翻译
wordwrap
''''''''
wordwrap
''''''''
5703天前 翻译
453#翻译
Example:
例如:
5856天前 翻译
456#翻译
Wraps words at a specified line length.
在指定长度将文字换行。
5856天前 翻译
457#翻译
yesno
'''''
yesno
'''''
5703天前 翻译
458#翻译
Example:
例如:
5856天前 翻译
461#翻译
Given a string mapping values for ``True`` , ``False`` , and (optionally) ``None``
, returns one of those strings according to the value (see Table F-4).
提供一个字符串参数对应着 true, false 和 (可选的) None, 根据被处理的值返回相应的字符串:
5200天前 翻译
462#翻译
.. table:: Table F-4. Examples of the yesno Filter

    +---------+-------------------+---------------------------------------------------+
    |Value    |Argument           |Output                                             |
    +=========+===================+===================================================+
    |``True`` |``"yeah,no,maybe"``|``yeah``                                           |
    +---------+-------------------+---------------------------------------------------+
    |``False``|``"yeah,no,maybe"``|``no``                                             |
    +---------+-------------------+---------------------------------------------------+
    |``None`` |``"yeah,no,maybe"``|``maybe``                                          |
    +---------+-------------------+---------------------------------------------------+
    |``None`` |``"yeah,no"``      |``"no"`` (converts ``None`` to ``False`` if no     |
    |         |                   |mapping for ``None`` is given)                     |
    +---------+-------------------+---------------------------------------------------+
    
.. table:: 表F-4. yesno过滤器示例

    +---------+-------------------+---------------------------------------------------+
    |值       |参数               |输出                                               |
    +=========+===================+===================================================+
    |``True`` |``"yeah,no,maybe"``|``yeah``                                           |
    +---------+-------------------+---------------------------------------------------+
    |``False``|``"yeah,no,maybe"``|``no``                                             |
    +---------+-------------------+---------------------------------------------------+
    |``None`` |``"yeah,no,maybe"``|``maybe``                                          |
    +---------+-------------------+---------------------------------------------------+
    |``None`` |``"yeah,no"``      |``"no"`` (如果不存在 ``None`` 的映射,将 ``None``  |
    |         |                   |变为 ``False`` )                                   |
    +---------+-------------------+---------------------------------------------------+
    

5205天前 翻译