10.1. Templatetags Filter¶
def cut(value, arg):
"""Removes all values of arg from the given string"""
return value.replace(arg, "")
10.1.1. Filters¶
lower
upper
title
date
default
timezone
custom filters
{% load tz %}
{{ value|timezone:"Europe/Paris" }}
{% load tz %}
{{ value|utc }}
{% load tz %}
{{ value|localtime }}
10.1.2. 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):
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 |
10.1.3. Simple Tags¶
trans
custom tags
10.1.4. Assignment tags¶
10.1.5. 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 %}