32. Templatetags

32.1. Rationale

Table 32.1. Templatetags

Argument

Outputs

openblock

{%

closeblock

%}

openvariable

{{

closevariable

}}

openbrace

{

closebrace

}

opencomment

{#

closecomment

#}

32.2. Filters

  • lower

  • upper

  • title

  • date

  • default

  • timezone

  • custom filters

{% load tz %}

{{ value|timezone:"Europe/Paris" }}
{% load tz %}

{{ value|utc }}
{% load tz %}

{{ value|localtime }}

32.3. Float Format

If the argument passed to floatformat has the g suffix, it will force grouping by the THOUSAND_SEPARATOR for the active locale. For example, when the active locale is en (English):

Table 32.2. Float Format

Value

Template

Output

34232.34

{{ value|floatformat:"2g" }}

34

232.34

34232.06

{{ value|floatformat:"g" }}

34

232.1

34232.00

{{ value|floatformat:"-3g" }}

34

232

32.4. Simple Tags

  • trans

  • custom tags

32.5. Assignment tags

32.6. Block tags

  • custom block tags

{% load tz %}

{% localtime on %}
    {{ value }}
{% endlocaltime %}

{% localtime off %}
    {{ value }}
{% endlocaltime %}
{% load tz %}

{% timezone "Europe/Paris" %}
    Paris time: {{ value }}
{% endtimezone %}

{% timezone None %}
    Server time: {{ value }}
{% endtimezone %}