{"title":"Etiket cetakan dan penyaring siap-pakai","version":"5.0","locale":"id","docname":"ref/templates/builtins","url":"/id/5.0/ref/templates/builtins/","canonical":"https://djangodocs.dev/id/5.0/ref/templates/builtins/","summary":"This document describes Django's built-in template tags and filters. It is recommended that you use the automatic documentation, if available, as this will…","html":"<h1>Etiket cetakan dan penyaring siap-pakai<a class=\"heading-anchor\" href=\"#built-in-template-tags-and-filters\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>This document describes Django's built-in template tags and filters. It is\nrecommended that you use the <a class=\"reference internal\" href=\"/id/5.0/ref/contrib/admin/admindocs/\"><span class=\"doc\">automatic documentation</span></a>, if available, as this will also include\ndocumentation for any custom tags or filters installed.</p>\n<section id=\"built-in-tag-reference\">\n<span id=\"ref-templates-builtins-tags\"></span><h2>Acuan etiket siap-pakai<a class=\"heading-anchor\" href=\"#built-in-tag-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"autoescape\">\n<span id=\"std-templatetag-autoescape\"></span><h3><code class=\"docutils literal notranslate\">autoescape</code><a class=\"heading-anchor\" href=\"#autoescape\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Controls the current auto-escaping behavior. This tag takes either <code class=\"docutils literal notranslate\">on</code> or\n<code class=\"docutils literal notranslate\">off</code> as an argument and that determines whether auto-escaping is in effect\ninside the block. The block is closed with an <code class=\"docutils literal notranslate\">endautoescape</code> ending tag.</p>\n<p>Sample usage:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">on</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">body</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>When auto-escaping is in effect, all content derived from variables has HTML\nescaping applied before placing the result into the output (but after any\nfilters are applied). This is equivalent to manually applying the\n<a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> filter to each variable.</p>\n<p>The only exceptions are variables already marked as &quot;safe&quot; from escaping.\nVariables could be marked as &quot;safe&quot; by the code which populated the variable,\nby applying the <a class=\"reference internal\" href=\"#std-templatefilter-safe\"><code class=\"xref std std-tfilter docutils literal notranslate\">safe</code></a> or <a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> filters, or because it's\nthe result of a previous filter that marked the string as &quot;safe&quot;.</p>\n<p>Within the scope of disabled auto-escaping, chaining filters, including\n<a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a>, may cause unexpected (but documented) results such as the\nfollowing:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">off</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">my_list</span><span class=\"o\">|</span><span class=\"nf\">join</span><span class=\"s2\">:&quot;, &quot;</span><span class=\"o\">|</span><span class=\"nf\">escape</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>The above code will output the joined elements of <code class=\"docutils literal notranslate\">my_list</code> unescaped. This\nis because the filter chaining sequence executes first <a class=\"reference internal\" href=\"#std-templatefilter-join\"><code class=\"xref std std-tfilter docutils literal notranslate\">join</code></a> on\n<code class=\"docutils literal notranslate\">my_list</code> (without applying escaping to each item since <code class=\"docutils literal notranslate\">autoescape</code> is\n<code class=\"docutils literal notranslate\">off</code>), marking the result as safe. Subsequently, this safe result will be\nfed to <a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> filter, which does not apply a second round of\nescaping.</p>\n<p>In order to properly escape every element in a sequence, use the\n<a class=\"reference internal\" href=\"#std-templatefilter-escapeseq\"><code class=\"xref std std-tfilter docutils literal notranslate\">escapeseq</code></a> filter:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">off</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">my_list</span><span class=\"o\">|</span><span class=\"nf\">escapeseq</span><span class=\"o\">|</span><span class=\"nf\">join</span><span class=\"s2\">:&quot;, &quot;</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"block\">\n<span id=\"std-templatetag-block\"></span><h3><code class=\"docutils literal notranslate\">block</code><a class=\"heading-anchor\" href=\"#block\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Defines a block that can be overridden by child templates. See\n<a class=\"reference internal\" href=\"/id/5.0/ref/templates/language/#template-inheritance\"><span class=\"std std-ref\">Template inheritance</span></a> for more information.</p>\n</section>\n<section id=\"comment\">\n<span id=\"std-templatetag-comment\"></span><h3><code class=\"docutils literal notranslate\">comment</code><a class=\"heading-anchor\" href=\"#comment\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Ignores everything between <code class=\"docutils literal notranslate\">{% comment %}</code> and <code class=\"docutils literal notranslate\">{% endcomment %}</code>.\nAn optional note may be inserted in the first tag. For example, this is\nuseful when commenting out code for documenting why the code was disabled.</p>\n<p>Sample usage:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>Rendered text with <span class=\"cp\">{{</span> <span class=\"nv\">pub_date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;c&quot;</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">comment</span> <span class=\"s2\">&quot;Optional note&quot;</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>Commented out text with <span class=\"cp\">{{</span> <span class=\"nv\">create_date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;c&quot;</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endcomment</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Etiket <code class=\"docutils literal notranslate\">comment</code> tidak dapat bersarang.</p>\n</section>\n<section id=\"csrf-token\">\n<span id=\"std-templatetag-csrf_token\"></span><h3><code class=\"docutils literal notranslate\">csrf_token</code><a class=\"heading-anchor\" href=\"#csrf-token\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This tag is used for CSRF protection, as described in the documentation for\n<a class=\"reference internal\" href=\"/id/5.0/ref/csrf/\"><span class=\"doc\">Cross Site Request Forgeries</span></a>.</p>\n</section>\n<section id=\"cycle\">\n<span id=\"std-templatetag-cycle\"></span><h3><code class=\"docutils literal notranslate\">cycle</code><a class=\"heading-anchor\" href=\"#cycle\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Produces one of its arguments each time this tag is encountered. The first\nargument is produced on the first encounter, the second argument on the second\nencounter, and so forth. Once all arguments are exhausted, the tag cycles to\nthe first argument and produces it again.</p>\n<p>This tag is particularly useful in a loop:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">o</span> <span class=\"k\">in</span> <span class=\"nv\">some_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">tr</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;row1&#39;</span> <span class=\"s1\">&#39;row2&#39;</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n        ...\n    <span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Perulangan pertama menghasilkan HTML yang mengacu pada kelas <code class=\"docutils literal notranslate\">row1</code>, kedua pada <code class=\"docutils literal notranslate\">row2</code>, ketiga pada <code class=\"docutils literal notranslate\">row1</code> kembali, dan seterusnya untuk setiap perulangan dari putaran.</p>\n<p>You can use variables, too. For example, if you have two template variables,\n<code class=\"docutils literal notranslate\">rowvalue1</code> and <code class=\"docutils literal notranslate\">rowvalue2</code>, you can alternate between their values like\nthis:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">o</span> <span class=\"k\">in</span> <span class=\"nv\">some_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">tr</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"nv\">rowvalue1</span> <span class=\"nv\">rowvalue2</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n        ...\n    <span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Variables included in the cycle will be escaped.  You can disable auto-escaping\nwith:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">o</span> <span class=\"k\">in</span> <span class=\"nv\">some_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">tr</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">off</span> <span class=\"cp\">%}{%</span> <span class=\"k\">cycle</span> <span class=\"nv\">rowvalue1</span> <span class=\"nv\">rowvalue2</span> <span class=\"cp\">%}{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n        ...\n    <span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>You can mix variables and strings:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">o</span> <span class=\"k\">in</span> <span class=\"nv\">some_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">tr</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;row1&#39;</span> <span class=\"nv\">rowvalue2</span> <span class=\"s1\">&#39;row3&#39;</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n        ...\n    <span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>In some cases you might want to refer to the current value of a cycle\nwithout advancing to the next value. To do this,\ngive the <code class=\"docutils literal notranslate\">{% cycle %}</code> tag a name, using &quot;as&quot;, like this:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;row1&#39;</span> <span class=\"s1\">&#39;row2&#39;</span> <span class=\"k\">as</span> <span class=\"nv\">rowcolors</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>From then on, you can insert the current value of the cycle wherever you'd like\nin your template by referencing the cycle name as a context variable. If you\nwant to move the cycle to the next value independently of the original\n<code class=\"docutils literal notranslate\">cycle</code> tag, you can use another <code class=\"docutils literal notranslate\">cycle</code> tag and specify the name of the\nvariable. So, the following template:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;row1&#39;</span> <span class=\"s1\">&#39;row2&#39;</span> <span class=\"k\">as</span> <span class=\"nv\">rowcolors</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">rowcolors</span> <span class=\"cp\">}}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"nv\">rowcolors</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">rowcolors</span> <span class=\"cp\">}}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>would output:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;row1&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;row1&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;row2&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">td</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;row2&quot;</span><span class=\"p\">&gt;</span>...<span class=\"p\">&lt;/</span><span class=\"nt\">td</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>You can use any number of values in a <code class=\"docutils literal notranslate\">cycle</code> tag, separated by spaces.\nValues enclosed in single quotes (<code class=\"docutils literal notranslate\">'</code>) or double quotes (<code class=\"docutils literal notranslate\">&quot;</code>) are treated\nas string literals, while values without quotes are treated as template\nvariables.</p>\n<p>By default, when you use the <code class=\"docutils literal notranslate\">as</code> keyword with the cycle tag, the\nusage of <code class=\"docutils literal notranslate\">{% cycle %}</code> that initiates the cycle will itself produce\nthe first value in the cycle. This could be a problem if you want to\nuse the value in a nested loop or an included template. If you only want\nto declare the cycle but not produce the first value, you can add a\n<code class=\"docutils literal notranslate\">silent</code> keyword as the last keyword in the tag. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">obj</span> <span class=\"k\">in</span> <span class=\"nv\">some_list</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;row1&#39;</span> <span class=\"s1\">&#39;row2&#39;</span> <span class=\"k\">as</span> <span class=\"nv\">rowcolors</span> <span class=\"nv\">silent</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">tr</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">rowcolors</span> <span class=\"cp\">}}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span><span class=\"cp\">{%</span> <span class=\"k\">include</span> <span class=\"s2\">&quot;subtemplate.html&quot;</span> <span class=\"cp\">%}</span><span class=\"p\">&lt;/</span><span class=\"nt\">tr</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>This will output a list of <code class=\"docutils literal notranslate\">&lt;tr&gt;</code> elements with <code class=\"docutils literal notranslate\">class</code>\nalternating between <code class=\"docutils literal notranslate\">row1</code> and <code class=\"docutils literal notranslate\">row2</code>. The subtemplate will have\naccess to <code class=\"docutils literal notranslate\">rowcolors</code> in its context and the value will match the class\nof the <code class=\"docutils literal notranslate\">&lt;tr&gt;</code> that encloses it. If the <code class=\"docutils literal notranslate\">silent</code> keyword were to be\nomitted, <code class=\"docutils literal notranslate\">row1</code> and <code class=\"docutils literal notranslate\">row2</code> would be emitted as normal text, outside the\n<code class=\"docutils literal notranslate\">&lt;tr&gt;</code> element.</p>\n<p>When the silent keyword is used on a cycle definition, the silence\nautomatically applies to all subsequent uses of that specific cycle tag.\nThe following template would output <em>nothing</em>, even though the second\ncall to <code class=\"docutils literal notranslate\">{% cycle %}</code> doesn't specify <code class=\"docutils literal notranslate\">silent</code>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;row1&#39;</span> <span class=\"s1\">&#39;row2&#39;</span> <span class=\"k\">as</span> <span class=\"nv\">rowcolors</span> <span class=\"nv\">silent</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"nv\">rowcolors</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Anda dapat menggunakan etiket <a class=\"reference internal\" href=\"#std-templatetag-resetcycle\"><code class=\"xref std std-ttag docutils literal notranslate\">resetcycle</code></a> untuk membuat sebuah etiket <code class=\"docutils literal notranslate\">{% cycle %}</code> mulai ulang dari nilai pertamanya ketika itu selanjutnya ditemui.</p>\n</section>\n<section id=\"debug\">\n<span id=\"std-templatetag-debug\"></span><h3><code class=\"docutils literal notranslate\">debug</code><a class=\"heading-anchor\" href=\"#debug\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Outputs a whole load of debugging information, including the current context\nand imported modules. <code class=\"docutils literal notranslate\">{% debug %}</code> outputs nothing when the <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a>\nsetting is <code class=\"docutils literal notranslate\">False</code>.</p>\n<aside class=\"version-note version-changed\" data-version=\"2.2.27\" role=\"note\">\n<p class=\"version-note-title\">Changed in Django 2.2.27</p><p>In older versions, debugging information was displayed when the\n<a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> setting was <code class=\"docutils literal notranslate\">False</code>.</p>\n</aside>\n</section>\n<section id=\"extends\">\n<span id=\"std-templatetag-extends\"></span><h3><code class=\"docutils literal notranslate\">extends</code><a class=\"heading-anchor\" href=\"#extends\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Sinyal-sinyal yang cetakan ini memperpanjang cetakan induk.</p>\n<p>Etiket ini dapat digunakan dalam dua cara:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">{% extends &quot;base.html&quot; %}</code> (with quotes) uses the literal value\n<code class=\"docutils literal notranslate\">&quot;base.html&quot;</code> as the name of the parent template to extend.</p></li>\n<li><p><code class=\"docutils literal notranslate\">{% extends variable %}</code> uses the value of <code class=\"docutils literal notranslate\">variable</code>. If the variable\nevaluates to a string, Django will use that string as the name of the\nparent template. If the variable evaluates to a <code class=\"docutils literal notranslate\">Template</code> object,\nDjango will use that object as the parent template.</p></li>\n</ul>\n<p>Lihat <a class=\"reference internal\" href=\"/id/5.0/ref/templates/language/#template-inheritance\"><span class=\"std std-ref\">Template inheritance</span></a> untuk informasi lebih.</p>\n<p>Normally the template name is relative to the template loader's root directory.\nA string argument may also be a relative path starting with <code class=\"docutils literal notranslate\">./</code> or <code class=\"docutils literal notranslate\">../</code>.\nFor example, assume the following directory structure:</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>dir1/\n    template.html\n    base2.html\n    my/\n        base3.html\nbase1.html\n</code></pre></div>\n<p>In <code class=\"docutils literal notranslate\">template.html</code>, the following paths would be valid:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">extends</span> <span class=\"s2\">&quot;./base2.html&quot;</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">extends</span> <span class=\"s2\">&quot;../base1.html&quot;</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">extends</span> <span class=\"s2\">&quot;./my/base3.html&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"filter\">\n<span id=\"std-templatetag-filter\"></span><h3><code class=\"docutils literal notranslate\">filter</code><a class=\"heading-anchor\" href=\"#filter\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Filters the contents of the block through one or more filters. Multiple\nfilters can be specified with pipes and filters can have arguments, just as\nin variable syntax.</p>\n<p>Catat bahwa blok menyertakan <em>semua</em> teks diantara etiket <code class=\"docutils literal notranslate\">filter</code> dan <code class=\"docutils literal notranslate\">endfilter</code>.</p>\n<p>Sample usage:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">filter</span> <span class=\"nf\">force_escape</span><span class=\"o\">|</span><span class=\"nf\">lower</span> <span class=\"cp\">%}</span>\n    This text will be HTML-escaped, and will appear in all lowercase.\n<span class=\"cp\">{%</span> <span class=\"k\">endfilter</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>The <a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> and <a class=\"reference internal\" href=\"#std-templatefilter-safe\"><code class=\"xref std std-tfilter docutils literal notranslate\">safe</code></a> filters are not acceptable\narguments. Instead, use the <a class=\"reference internal\" href=\"#std-templatetag-autoescape\"><code class=\"xref std std-ttag docutils literal notranslate\">autoescape</code></a> tag to manage autoescaping\nfor blocks of template code.</p>\n</aside>\n</section>\n<section id=\"firstof\">\n<span id=\"std-templatetag-firstof\"></span><h3><code class=\"docutils literal notranslate\">firstof</code><a class=\"heading-anchor\" href=\"#firstof\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Outputs the first argument variable that is not &quot;false&quot; (i.e. exists, is not\nempty, is not a false boolean value, and is not a zero numeric value). Outputs\nnothing if all the passed variables are &quot;false&quot;.</p>\n<p>Sample usage:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">firstof</span> <span class=\"nv\">var1</span> <span class=\"nv\">var2</span> <span class=\"nv\">var3</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>This is equivalent to:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">var1</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">var1</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">elif</span> <span class=\"nv\">var2</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">var2</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">elif</span> <span class=\"nv\">var3</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">var3</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>You can also use a literal string as a fallback value in case all\npassed variables are False:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">firstof</span> <span class=\"nv\">var1</span> <span class=\"nv\">var2</span> <span class=\"nv\">var3</span> <span class=\"s2\">&quot;fallback value&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>This tag auto-escapes variable values. You can disable auto-escaping with:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">off</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">firstof</span> <span class=\"nv\">var1</span> <span class=\"nv\">var2</span> <span class=\"nv\">var3</span> <span class=\"s2\">&quot;&lt;strong&gt;fallback value&lt;/strong&gt;&quot;</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Or if only some variables should be escaped, you can use:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">firstof</span> <span class=\"nv\">var1</span> <span class=\"nv\">var2</span><span class=\"o\">|</span><span class=\"nf\">safe</span> <span class=\"nv\">var3</span> <span class=\"s2\">&quot;&lt;strong&gt;fallback value&lt;/strong&gt;&quot;</span><span class=\"o\">|</span><span class=\"nf\">safe</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>You can use the syntax <code class=\"docutils literal notranslate\">{% firstof var1 var2 var3 as value %}</code> to store the\noutput inside a variable.</p>\n</section>\n<section id=\"for\">\n<span id=\"std-templatetag-for\"></span><h3><code class=\"docutils literal notranslate\">for</code><a class=\"heading-anchor\" href=\"#for\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Loops over each item in an array, making the item available in a context\nvariable. For example, to display a list of athletes provided in\n<code class=\"docutils literal notranslate\">athlete_list</code>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">athlete</span> <span class=\"k\">in</span> <span class=\"nv\">athlete_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">athlete.name</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>Anda dapat memutar kembali daftar dalam kebalikan dengan menggunakan <code class=\"docutils literal notranslate\">{% for obj in list reversed %}</code>.</p>\n<p>If you need to loop over a list of lists, you can unpack the values\nin each sublist into individual variables. For example, if your context\ncontains a list of (x,y) coordinates called <code class=\"docutils literal notranslate\">points</code>, you could use the\nfollowing to output the list of points:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">x</span><span class=\"o\">,</span> <span class=\"nv\">y</span> <span class=\"k\">in</span> <span class=\"nv\">points</span> <span class=\"cp\">%}</span>\n    There is a point at <span class=\"cp\">{{</span> <span class=\"nv\">x</span> <span class=\"cp\">}}</span>,<span class=\"cp\">{{</span> <span class=\"nv\">y</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>This can also be useful if you need to access the items in a dictionary.\nFor example, if your context contained a dictionary <code class=\"docutils literal notranslate\">data</code>, the following\nwould display the keys and values of the dictionary:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">key</span><span class=\"o\">,</span> <span class=\"nv\">value</span> <span class=\"k\">in</span> <span class=\"nv\">data.items</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">key</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">value</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Keep in mind that for the dot operator, dictionary key lookup takes precedence\nover method lookup. Therefore if the <code class=\"docutils literal notranslate\">data</code> dictionary contains a key named\n<code class=\"docutils literal notranslate\">'items'</code>, <code class=\"docutils literal notranslate\">data.items</code> will return <code class=\"docutils literal notranslate\">data['items']</code> instead of\n<code class=\"docutils literal notranslate\">data.items()</code>. Avoid adding keys that are named like dictionary methods if\nyou want to use those methods in a template (<code class=\"docutils literal notranslate\">items</code>, <code class=\"docutils literal notranslate\">values</code>, <code class=\"docutils literal notranslate\">keys</code>,\netc.). Read more about the lookup order of the dot operator in the\n<a class=\"reference internal\" href=\"/id/5.0/ref/templates/language/#template-variables\"><span class=\"std std-ref\">documentation of template variables</span></a>.</p>\n<p>Putaran for mensetel angka dari variabel-variabel tersedia dalam putaran.</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Variabel</p></th>\n<th class=\"head\"><p>Deskripsi</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">forloop.counter</code></p></td>\n<td><p>Perulangan saat ini dari putaran (indeks-1)</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">forloop.counter0</code></p></td>\n<td><p>Perulangan saat ini dari putaran (indeks-0)</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">forloop.revcounter</code></p></td>\n<td><p>Jumlah perulangan dari akhir dari putaran (indeks-1)</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">forloop.revcounter0</code></p></td>\n<td><p>Jumlah perulangan dari akhir dari perputaran (indeks-0)</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">forloop.first</code></p></td>\n<td><p>True jika ini adalah waktu pertama melalui perulangan</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">forloop.last</code></p></td>\n<td><p>True jika ini adalah waktu terakhir melalui perulangan</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">forloop.parentloop</code></p></td>\n<td><p>Untuk perulangan bersarang, ini adalah perulangan disekitar satu saat ini</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n</section>\n<section id=\"for-empty\">\n<h3><code class=\"docutils literal notranslate\">for</code> ... <code class=\"docutils literal notranslate\">empty</code><a class=\"heading-anchor\" href=\"#for-empty\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">for</code> tag can take an optional <code class=\"docutils literal notranslate\">{% empty %}</code> clause whose text is\ndisplayed if the given array is empty or could not be found:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">athlete</span> <span class=\"k\">in</span> <span class=\"nv\">athlete_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">athlete.name</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">empty</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>Sorry, no athletes in this list.<span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>The above is equivalent to -- but shorter, cleaner, and possibly faster\nthan -- the following:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n  <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">athlete_list</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">athlete</span> <span class=\"k\">in</span> <span class=\"nv\">athlete_list</span> <span class=\"cp\">%}</span>\n      <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">athlete.name</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n  <span class=\"cp\">{%</span> <span class=\"k\">else</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>Sorry, no athletes in this list.<span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n  <span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</section>\n<section id=\"if\">\n<span id=\"std-templatetag-if\"></span><h3><code class=\"docutils literal notranslate\">if</code><a class=\"heading-anchor\" href=\"#if\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">{% if %}</code> tag evaluates a variable, and if that variable is &quot;true&quot; (i.e.\nexists, is not empty, and is not a false boolean value) the contents of the\nblock are output:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">athlete_list</span> <span class=\"cp\">%}</span>\n    Number of athletes: <span class=\"cp\">{{</span> <span class=\"nv\">athlete_list</span><span class=\"o\">|</span><span class=\"nf\">length</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">elif</span> <span class=\"nv\">athlete_in_locker_room_list</span> <span class=\"cp\">%}</span>\n    Athletes should be out of the locker room soon!\n<span class=\"cp\">{%</span> <span class=\"k\">else</span> <span class=\"cp\">%}</span>\n    No athletes.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>In the above, if <code class=\"docutils literal notranslate\">athlete_list</code> is not empty, the number of athletes will be\ndisplayed by the <code class=\"docutils literal notranslate\">{{ athlete_list|length }}</code> variable.</p>\n<p>As you can see, the <code class=\"docutils literal notranslate\">if</code> tag may take one or several <code class=\"docutils literal notranslate\">{% elif %}</code>\nclauses, as well as an <code class=\"docutils literal notranslate\">{% else %}</code> clause that will be displayed if all\nprevious conditions fail. These clauses are optional.</p>\n<section id=\"boolean-operators\">\n<h4>Penghubung Boolean<a class=\"heading-anchor\" href=\"#boolean-operators\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> tags may use <code class=\"docutils literal notranslate\">and</code>, <code class=\"docutils literal notranslate\">or</code> or <code class=\"docutils literal notranslate\">not</code> to test a number of\nvariables or to negate a given variable:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">athlete_list</span> <span class=\"k\">and</span> <span class=\"nv\">coach_list</span> <span class=\"cp\">%}</span>\n    Both athletes and coaches are available.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"k\">not</span> <span class=\"nv\">athlete_list</span> <span class=\"cp\">%}</span>\n    There are no athletes.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">athlete_list</span> <span class=\"k\">or</span> <span class=\"nv\">coach_list</span> <span class=\"cp\">%}</span>\n    There are some athletes or some coaches.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"k\">not</span> <span class=\"nv\">athlete_list</span> <span class=\"k\">or</span> <span class=\"nv\">coach_list</span> <span class=\"cp\">%}</span>\n    There are no athletes or there are some coaches.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">athlete_list</span> <span class=\"k\">and</span> <span class=\"k\">not</span> <span class=\"nv\">coach_list</span> <span class=\"cp\">%}</span>\n    There are some athletes and absolutely no coaches.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Use of both <code class=\"docutils literal notranslate\">and</code> and <code class=\"docutils literal notranslate\">or</code> clauses within the same tag is allowed, with\n<code class=\"docutils literal notranslate\">and</code> having higher precedence than <code class=\"docutils literal notranslate\">or</code> e.g.:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">athlete_list</span> <span class=\"k\">and</span> <span class=\"nv\">coach_list</span> <span class=\"k\">or</span> <span class=\"nv\">cheerleader_list</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>will be interpreted like:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">if</span> <span class=\"p\">(</span>athlete_list <span class=\"ow\">and</span> coach_list<span class=\"p\">)</span> <span class=\"ow\">or</span> cheerleader_list<span class=\"p\">:</span>\n    <span class=\"o\">...</span>\n</code></pre></div>\n<p>Use of actual parentheses in the <a class=\"reference internal\" href=\"#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> tag is invalid syntax. If you need\nthem to indicate precedence, you should use nested <a class=\"reference internal\" href=\"#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> tags.</p>\n<p><a class=\"reference internal\" href=\"#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> etiket mungkin juga menggunakan penghubung <code class=\"docutils literal notranslate\">==</code>, <code class=\"docutils literal notranslate\">!=</code>, <code class=\"docutils literal notranslate\">&lt;</code>, <code class=\"docutils literal notranslate\">&gt;</code>, <code class=\"docutils literal notranslate\">&lt;=</code>, <code class=\"docutils literal notranslate\">&gt;=</code>, <code class=\"docutils literal notranslate\">in</code>, <code class=\"docutils literal notranslate\">not in</code>, <code class=\"docutils literal notranslate\">is</code>, dan <code class=\"docutils literal notranslate\">is not</code> yang bekerja sebagai berikut:</p>\n<section id=\"operator\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">==</code><a class=\"heading-anchor\" href=\"#operator\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Equality. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"o\">==</span> <span class=\"s2\">&quot;x&quot;</span> <span class=\"cp\">%}</span>\n  This appears if variable somevar equals the string &quot;x&quot;\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"id1\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">!=</code><a class=\"heading-anchor\" href=\"#id1\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Inequality. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"o\">!=</span> <span class=\"s2\">&quot;x&quot;</span> <span class=\"cp\">%}</span>\n  This appears if variable somevar does not equal the string &quot;x&quot;,\n  or if somevar is not found in the context\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"id2\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">&lt;</code><a class=\"heading-anchor\" href=\"#id2\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Less than. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"o\">&lt;</span> <span class=\"m\">100</span> <span class=\"cp\">%}</span>\n  This appears if variable somevar is less than 100.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"id3\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">&gt;</code><a class=\"heading-anchor\" href=\"#id3\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Greater than. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"o\">&gt;</span> <span class=\"m\">0</span> <span class=\"cp\">%}</span>\n  This appears if variable somevar is greater than 0.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"id4\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">&lt;=</code><a class=\"heading-anchor\" href=\"#id4\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Less than or equal to. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"o\">&lt;=</span> <span class=\"m\">100</span> <span class=\"cp\">%}</span>\n  This appears if variable somevar is less than 100 or equal to 100.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"id5\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">&gt;=</code><a class=\"heading-anchor\" href=\"#id5\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Greater than or equal to. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"o\">&gt;=</span> <span class=\"m\">1</span> <span class=\"cp\">%}</span>\n  This appears if variable somevar is greater than 1 or equal to 1.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"in-operator\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">in</code><a class=\"heading-anchor\" href=\"#in-operator\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Contained within. This operator is supported by many Python containers to test\nwhether the given value is in the container. The following are some examples\nof how <code class=\"docutils literal notranslate\">x in y</code> will be interpreted:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"s2\">&quot;bc&quot;</span> <span class=\"k\">in</span> <span class=\"s2\">&quot;abcdef&quot;</span> <span class=\"cp\">%}</span>\n  This appears since &quot;bc&quot; is a substring of &quot;abcdef&quot;\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"s2\">&quot;hello&quot;</span> <span class=\"k\">in</span> <span class=\"nv\">greetings</span> <span class=\"cp\">%}</span>\n  If greetings is a list or set, one element of which is the string\n  &quot;hello&quot;, this will appear.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">user</span> <span class=\"k\">in</span> <span class=\"nv\">users</span> <span class=\"cp\">%}</span>\n  If users is a QuerySet, this will appear if user is an\n  instance that belongs to the QuerySet.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"not-in-operator\">\n<h5>Penghubung <code class=\"docutils literal notranslate\">not in</code><a class=\"heading-anchor\" href=\"#not-in-operator\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Tidak terkandung dalam. Ini adalah lawan dari penghubung <code class=\"docutils literal notranslate\">in</code>.</p>\n</section>\n<section id=\"is-operator\">\n<h5>penghubung <code class=\"docutils literal notranslate\">is</code><a class=\"heading-anchor\" href=\"#is-operator\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Object identity. Tests if two values are the same object. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"k\">is</span> <span class=\"nf\">True</span> <span class=\"cp\">%}</span>\n  This appears if and only if somevar is True.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"k\">is</span> <span class=\"nf\">None</span> <span class=\"cp\">%}</span>\n  This appears if somevar is None, or if somevar is not found in the context.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"is-not-operator\">\n<h5>penghubung <code class=\"docutils literal notranslate\">is not</code><a class=\"heading-anchor\" href=\"#is-not-operator\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p>Negated object identity. Tests if two values are not the same object. This is\nthe negation of the <code class=\"docutils literal notranslate\">is</code> operator. Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"k\">is</span> <span class=\"k\">not</span> <span class=\"nf\">True</span> <span class=\"cp\">%}</span>\n  This appears if somevar is not True, or if somevar is not found in the\n  context.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">somevar</span> <span class=\"k\">is</span> <span class=\"k\">not</span> <span class=\"nf\">None</span> <span class=\"cp\">%}</span>\n  This appears if and only if somevar is not None.\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"filters\">\n<h4>Filter<a class=\"heading-anchor\" href=\"#filters\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>You can also use filters in the <a class=\"reference internal\" href=\"#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> expression. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">messages</span><span class=\"o\">|</span><span class=\"nf\">length</span> <span class=\"o\">&gt;=</span> <span class=\"m\">100</span> <span class=\"cp\">%}</span>\n   You have lots of messages today!\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"complex-expressions\">\n<h4>Pernyataan rumit<a class=\"heading-anchor\" href=\"#complex-expressions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>All of the above can be combined to form complex expressions. For such\nexpressions, it can be important to know how the operators are grouped when the\nexpression is evaluated - that is, the precedence rules. The precedence of the\noperators, from lowest to highest, is as follows:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">or</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">and</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">not</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">in</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">==</code>, <code class=\"docutils literal notranslate\">!=</code>, <code class=\"docutils literal notranslate\">&lt;</code>, <code class=\"docutils literal notranslate\">&gt;</code>, <code class=\"docutils literal notranslate\">&lt;=</code>, <code class=\"docutils literal notranslate\">&gt;=</code></p></li>\n</ul>\n<p>(This follows Python exactly). So, for example, the following complex\n<a class=\"reference internal\" href=\"#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> tag:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">a</span> <span class=\"o\">==</span> <span class=\"nv\">b</span> <span class=\"k\">or</span> <span class=\"nv\">c</span> <span class=\"o\">==</span> <span class=\"nv\">d</span> <span class=\"k\">and</span> <span class=\"nv\">e</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>...akan diartikan sebagai:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"p\">(</span>a <span class=\"o\">==</span> b<span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">((</span>c <span class=\"o\">==</span> d<span class=\"p\">)</span> <span class=\"ow\">and</span> e<span class=\"p\">)</span>\n</code></pre></div>\n<p>If you need different precedence, you will need to use nested <a class=\"reference internal\" href=\"#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> tags.\nSometimes that is better for clarity anyway, for the sake of those who do not\nknow the precedence rules.</p>\n<p>The comparison operators cannot be 'chained' like in Python or in mathematical\nnotation. For example, instead of using:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">a</span> <span class=\"o\">&gt;</span> <span class=\"nv\">b</span> <span class=\"o\">&gt;</span> <span class=\"nv\">c</span> <span class=\"cp\">%}</span>  (WRONG)\n</code></pre></div>\n<p>you should use:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">a</span> <span class=\"o\">&gt;</span> <span class=\"nv\">b</span> <span class=\"k\">and</span> <span class=\"nv\">b</span> <span class=\"o\">&gt;</span> <span class=\"nv\">c</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"ifchanged\">\n<span id=\"std-templatetag-ifchanged\"></span><h3><code class=\"docutils literal notranslate\">ifchanged</code><a class=\"heading-anchor\" href=\"#ifchanged\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Periksa jika nilai telah berubah dari putaran terakhir dari perulangan.</p>\n<p>Etiket blok <code class=\"docutils literal notranslate\">{% ifchanged %}</code> digunakan dalam perulangan. Itu mempunyai dua kemungkinan penggunaan.</p>\n<ol class=\"arabic\">\n<li><p>Checks its own rendered contents against its previous state and only\ndisplays the content if it has changed. For example, this displays a list of\ndays, only displaying the month if it changes:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>Archive for <span class=\"cp\">{{</span> <span class=\"nv\">year</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n\n<span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">date</span> <span class=\"k\">in</span> <span class=\"nv\">days</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">ifchanged</span> <span class=\"cp\">%}</span><span class=\"p\">&lt;</span><span class=\"nt\">h3</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;F&quot;</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h3</span><span class=\"p\">&gt;</span><span class=\"cp\">{%</span> <span class=\"k\">endifchanged</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">a</span> <span class=\"na\">href</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;M/d&quot;</span><span class=\"o\">|</span><span class=\"nf\">lower</span> <span class=\"cp\">}}</span><span class=\"s\">/&quot;</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;j&quot;</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">a</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</li>\n<li><p>If given one or more variables, check whether any variable has changed.\nFor example, the following shows the date every time it changes, while\nshowing the hour if either the hour or the date has changed:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">date</span> <span class=\"k\">in</span> <span class=\"nv\">days</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">ifchanged</span> <span class=\"nv\">date.date</span> <span class=\"cp\">%}</span> <span class=\"cp\">{{</span> <span class=\"nv\">date.date</span> <span class=\"cp\">}}</span> <span class=\"cp\">{%</span> <span class=\"k\">endifchanged</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">ifchanged</span> <span class=\"nv\">date.hour</span> <span class=\"nv\">date.date</span> <span class=\"cp\">%}</span>\n        <span class=\"cp\">{{</span> <span class=\"nv\">date.hour</span> <span class=\"cp\">}}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endifchanged</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</li>\n</ol>\n<p>The <code class=\"docutils literal notranslate\">ifchanged</code> tag can also take an optional <code class=\"docutils literal notranslate\">{% else %}</code> clause that\nwill be displayed if the value has not changed:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">match</span> <span class=\"k\">in</span> <span class=\"nv\">matches</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">div</span> <span class=\"na\">style</span><span class=\"o\">=</span><span class=\"s\">&quot;background-color:</span>\n<span class=\"s\">        </span><span class=\"cp\">{%</span> <span class=\"k\">ifchanged</span> <span class=\"nv\">match.ballot_id</span> <span class=\"cp\">%}</span>\n<span class=\"s\">            </span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s2\">&quot;red&quot;</span> <span class=\"s2\">&quot;blue&quot;</span> <span class=\"cp\">%}</span>\n<span class=\"s\">        </span><span class=\"cp\">{%</span> <span class=\"k\">else</span> <span class=\"cp\">%}</span>\n<span class=\"s\">            gray</span>\n<span class=\"s\">        </span><span class=\"cp\">{%</span> <span class=\"k\">endifchanged</span> <span class=\"cp\">%}</span>\n<span class=\"s\">    &quot;</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">match</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">div</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"include\">\n<span id=\"std-templatetag-include\"></span><h3><code class=\"docutils literal notranslate\">include</code><a class=\"heading-anchor\" href=\"#include\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Loads a template and renders it with the current context. This is a way of\n&quot;including&quot; other templates within a template.</p>\n<p>The template name can either be a variable or a hard-coded (quoted) string,\nin either single or double quotes.</p>\n<p>This example includes the contents of the template <code class=\"docutils literal notranslate\">&quot;foo/bar.html&quot;</code>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">include</span> <span class=\"s2\">&quot;foo/bar.html&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Normally the template name is relative to the template loader's root directory.\nA string argument may also be a relative path starting with <code class=\"docutils literal notranslate\">./</code> or <code class=\"docutils literal notranslate\">../</code>\nas described in the <a class=\"reference internal\" href=\"#std-templatetag-extends\"><code class=\"xref std std-ttag docutils literal notranslate\">extends</code></a> tag.</p>\n<p>This example includes the contents of the template whose name is contained in\nthe variable <code class=\"docutils literal notranslate\">template_name</code>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">include</span> <span class=\"nv\">template_name</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>The variable may also be any object with a <code class=\"docutils literal notranslate\">render()</code> method that accepts a\ncontext. This allows you to reference a compiled <code class=\"docutils literal notranslate\">Template</code> in your context.</p>\n<p>Additionally, the variable may be an iterable of template names, in which case\nthe first that can be loaded will be used, as per\n<a class=\"reference internal\" href=\"/id/5.0/topics/templates/#django.template.loader.select_template\" title=\"django.template.loader.select_template\"><code class=\"xref py py-func docutils literal notranslate\">select_template()</code></a>.</p>\n<p>An included template is rendered within the context of the template that\nincludes it. This example produces the output <code class=\"docutils literal notranslate\">&quot;Hello, John!&quot;</code>:</p>\n<ul>\n<li><p>Konteks: variabel <code class=\"docutils literal notranslate\">person``disetel menjadi ``&quot;John&quot;</code> dan variabel <code class=\"docutils literal notranslate\">greeting</code> disetel menjadi <code class=\"docutils literal notranslate\">&quot;Hello&quot;</code>.</p></li>\n<li><p>Template:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">include</span> <span class=\"s2\">&quot;name_snippet.html&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</li>\n<li><p>The <code class=\"docutils literal notranslate\">name_snippet.html</code> template:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">greeting</span> <span class=\"cp\">}}</span>, <span class=\"cp\">{{</span> <span class=\"nv\">person</span><span class=\"o\">|</span><span class=\"nf\">default</span><span class=\"s2\">:&quot;friend&quot;</span> <span class=\"cp\">}}</span>!\n</code></pre></div>\n</li>\n</ul>\n<p>You can pass additional context to the template using keyword arguments:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">include</span> <span class=\"s2\">&quot;name_snippet.html&quot;</span> <span class=\"k\">with</span> <span class=\"nv\">person</span><span class=\"o\">=</span><span class=\"s2\">&quot;Jane&quot;</span> <span class=\"nv\">greeting</span><span class=\"o\">=</span><span class=\"s2\">&quot;Hello&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>If you want to render the context only with the variables provided (or even\nno variables at all), use the <code class=\"docutils literal notranslate\">only</code> option. No other variables are\navailable to the included template:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">include</span> <span class=\"s2\">&quot;name_snippet.html&quot;</span> <span class=\"k\">with</span> <span class=\"nv\">greeting</span><span class=\"o\">=</span><span class=\"s2\">&quot;Hi&quot;</span> <span class=\"nv\">only</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>The <a class=\"reference internal\" href=\"#std-templatetag-include\"><code class=\"xref std std-ttag docutils literal notranslate\">include</code></a> tag should be considered as an implementation of\n&quot;render this subtemplate and include the HTML&quot;, not as &quot;parse this\nsubtemplate and include its contents as if it were part of the parent&quot;.\nThis means that there is no shared state between included templates --\neach include is a completely independent rendering process.</p>\n<p>Blocks are evaluated <em>before</em> they are included. This means that a template\nthat includes blocks from another will contain blocks that have <em>already\nbeen evaluated and rendered</em> - not blocks that can be overridden by, for\nexample, an extending template.</p>\n</aside>\n</section>\n<section id=\"load\">\n<span id=\"std-templatetag-load\"></span><h3><code class=\"docutils literal notranslate\">load</code><a class=\"heading-anchor\" href=\"#load\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Memuat kumpulan etiket cetakan penyesuaian.</p>\n<p>For example, the following template would load all the tags and filters\nregistered in <code class=\"docutils literal notranslate\">somelibrary</code> and <code class=\"docutils literal notranslate\">otherlibrary</code> located in package\n<code class=\"docutils literal notranslate\">package</code>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">somelibrary</span> <span class=\"nv\">package.otherlibrary</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>You can also selectively load individual filters or tags from a library, using\nthe <code class=\"docutils literal notranslate\">from</code> argument. In this example, the template tags/filters named <code class=\"docutils literal notranslate\">foo</code>\nand <code class=\"docutils literal notranslate\">bar</code> will be loaded from <code class=\"docutils literal notranslate\">somelibrary</code>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">foo</span> <span class=\"nv\">bar</span> <span class=\"nv\">from</span> <span class=\"nv\">somelibrary</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Lihat <a class=\"reference internal\" href=\"/id/5.0/howto/custom-template-tags/\"><span class=\"doc\">Custom tag and filter libraries</span></a> untuk informasi lebih.</p>\n</section>\n<section id=\"lorem\">\n<span id=\"std-templatetag-lorem\"></span><h3><code class=\"docutils literal notranslate\">lorem</code><a class=\"heading-anchor\" href=\"#lorem\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Menampilkan teks latin &quot;lorem ipsum&quot; acak. Ini berguna untuk menyediakan contoh data dalam cetakan.</p>\n<p>Penggunaan:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">lorem</span> <span class=\"o\">[</span><span class=\"nv\">count</span><span class=\"o\">]</span> <span class=\"o\">[</span><span class=\"nv\">method</span><span class=\"o\">]</span> <span class=\"o\">[</span><span class=\"nv\">random</span><span class=\"o\">]</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Etiket <code class=\"docutils literal notranslate\">{% lorem %}</code> dapat digunakan dengan nol, satu, dua atau tiga argumen. Argumennya adalah:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Argument</p></th>\n<th class=\"head\"><p>Deskripsi</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">count</code></p></td>\n<td><p>Sejumlah (atau variabel) mengandung sejumlah paragraf atau kata-kata untuk membangkitkan (awalan adalah 1).</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">method</code></p></td>\n<td><p>Antara <code class=\"docutils literal notranslate\">w</code> untuk kata-kata, <code class=\"docutils literal notranslate\">p</code> untuk paragraf HTML atau <code class=\"docutils literal notranslate\">b</code> untuk blok-blok paragraf teks-polos (awalan <code class=\"docutils literal notranslate\">b</code>).</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">random</code></p></td>\n<td><p>Kata <code class=\"docutils literal notranslate\">random</code>, yang jika diberikan, tiadk menggunakan paragraf umum (&quot;Lorem ipsum dolor sit amet...&quot;) ketika membangkitkan teks.</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Contoh:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">{% lorem %}</code> akan mengeluarkan paragraf umum &quot;lorem ipsum&quot;.</p></li>\n<li><p><code class=\"docutils literal notranslate\">{% lorem 3 p %}</code> akan mengeluarkan paragraf umum &quot;lorem ipsum&quot; dan dua paragraf acak masing-masing dibungkus daam etiket HTML <code class=\"docutils literal notranslate\">&lt;p&gt;</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">{% lorem 2 w random %}</code> akan mengeluarkan dua kata Latin acak.</p></li>\n</ul>\n</section>\n<section id=\"now\">\n<span id=\"std-templatetag-now\"></span><h3><code class=\"docutils literal notranslate\">now</code><a class=\"heading-anchor\" href=\"#now\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Displays the current date and/or time, using a format according to the given\nstring. Such string can contain format specifiers characters as described\nin the <a class=\"reference internal\" href=\"#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> filter section.</p>\n<p>Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>It is <span class=\"cp\">{%</span> <span class=\"k\">now</span> <span class=\"s2\">&quot;jS F Y H:i&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Note that you can backslash-escape a format string if you want to use the\n&quot;raw&quot; value. In this example, both &quot;o&quot; and &quot;f&quot; are backslash-escaped, because\notherwise each is a format string that displays the year and the time,\nrespectively:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>It is the <span class=\"cp\">{%</span> <span class=\"k\">now</span> <span class=\"s2\">&quot;jS \\o\\f F&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Ini akan ditampilkan sebagai &quot;It is the 4th of September&quot;.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>The format passed can also be one of the predefined ones\n<a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-DATE_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">DATE_FORMAT</code></a>, <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-DATETIME_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">DATETIME_FORMAT</code></a>,\n<a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-SHORT_DATE_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">SHORT_DATE_FORMAT</code></a> or <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-SHORT_DATETIME_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">SHORT_DATETIME_FORMAT</code></a>.\nThe predefined formats may vary depending on the current locale and\nif <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/formatting/\"><span class=\"doc\">Bentuk lokalisasi</span></a> is enabled, e.g.:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>It is <span class=\"cp\">{%</span> <span class=\"k\">now</span> <span class=\"s2\">&quot;SHORT_DATETIME_FORMAT&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</aside>\n<p>You can also use the syntax <code class=\"docutils literal notranslate\">{% now &quot;Y&quot; as current_year %}</code> to store the\noutput (as a string) inside a variable. This is useful if you want to use\n<code class=\"docutils literal notranslate\">{% now %}</code> inside a template tag like <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/translation/#std-templatetag-blocktranslate\"><code class=\"xref std std-ttag docutils literal notranslate\">blocktranslate</code></a> for example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">now</span> <span class=\"s2\">&quot;Y&quot;</span> <span class=\"k\">as</span> <span class=\"nv\">current_year</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">blocktranslate</span> <span class=\"cp\">%}</span>Copyright <span class=\"cp\">{{</span> <span class=\"nv\">current_year</span> <span class=\"cp\">}}{%</span> <span class=\"k\">endblocktranslate</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"regroup\">\n<span id=\"std-templatetag-regroup\"></span><h3><code class=\"docutils literal notranslate\">regroup</code><a class=\"heading-anchor\" href=\"#regroup\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Regroups a list of alike objects by a common attribute.</p>\n<p>This complex tag is best illustrated by way of an example: say that <code class=\"docutils literal notranslate\">cities</code>\nis a list of cities represented by dictionaries containing <code class=\"docutils literal notranslate\">&quot;name&quot;</code>,\n<code class=\"docutils literal notranslate\">&quot;population&quot;</code>, and <code class=\"docutils literal notranslate\">&quot;country&quot;</code> keys:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code>cities <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Mumbai&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;19,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;India&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Calcutta&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;15,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;India&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;New York&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;20,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;USA&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Chicago&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;7,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;USA&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Tokyo&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;33,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Japan&quot;</span><span class=\"p\">},</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>...dan anda ingin menampilkan daftar susunan bertingkat yang diurutkan berdasarkan negara, seperti ini:</p>\n<ul class=\"simple\">\n<li><p>India</p>\n<ul>\n<li><p>Mumbai: 19,000,000</p></li>\n<li><p>Calcutta: 15,000,000</p></li>\n</ul>\n</li>\n<li><p>USA</p>\n<ul>\n<li><p>New York: 20,000,000</p></li>\n<li><p>Chicago: 7,000,000</p></li>\n</ul>\n</li>\n<li><p>Jepang</p>\n<ul>\n<li><p>Tokyo: 33,000,000</p></li>\n</ul>\n</li>\n</ul>\n<p>You can use the <code class=\"docutils literal notranslate\">{% regroup %}</code> tag to group the list of cities by country.\nThe following snippet of template code would accomplish this:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">regroup</span> <span class=\"nv\">cities</span> <span class=\"nv\">by</span> <span class=\"nv\">country</span> <span class=\"k\">as</span> <span class=\"nv\">country_list</span> <span class=\"cp\">%}</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">country</span> <span class=\"k\">in</span> <span class=\"nv\">country_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">country.grouper</span> <span class=\"cp\">}}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n        <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">city</span> <span class=\"k\">in</span> <span class=\"nv\">country.list</span> <span class=\"cp\">%}</span>\n          <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">city.name</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">city.population</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n        <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>Let's walk through this example. <code class=\"docutils literal notranslate\">{% regroup %}</code> takes three arguments: the\nlist you want to regroup, the attribute to group by, and the name of the\nresulting list. Here, we're regrouping the <code class=\"docutils literal notranslate\">cities</code> list by the <code class=\"docutils literal notranslate\">country</code>\nattribute and calling the result <code class=\"docutils literal notranslate\">country_list</code>.</p>\n<p><code class=\"docutils literal notranslate\">{% regroup %}</code> produces a list (in this case, <code class=\"docutils literal notranslate\">country_list</code>) of\n<strong>group objects</strong>. Group objects are instances of\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/collections.html#collections.namedtuple\" title=\"(di Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">namedtuple()</code></a> with two fields:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">grouper</code> -- brang dikelompokkan berdasarkan (misalnya, string &quot;India&quot; atau &quot;Japan&quot;).</p></li>\n<li><p><code class=\"docutils literal notranslate\">list</code> -- sebuah daftar dari semua barang dalam kelompok ini (misalnya, sebuah daftar dari semua kota dengan negara='India').</p></li>\n</ul>\n<p>Because <code class=\"docutils literal notranslate\">{% regroup %}</code> produces <a class=\"reference external\" href=\"https://docs.python.org/3/library/collections.html#collections.namedtuple\" title=\"(di Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">namedtuple()</code></a> objects,\nyou can also write the previous example as:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">regroup</span> <span class=\"nv\">cities</span> <span class=\"nv\">by</span> <span class=\"nv\">country</span> <span class=\"k\">as</span> <span class=\"nv\">country_list</span> <span class=\"cp\">%}</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">country</span><span class=\"o\">,</span> <span class=\"nv\">local_cities</span> <span class=\"k\">in</span> <span class=\"nv\">country_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">country</span> <span class=\"cp\">}}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n        <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">city</span> <span class=\"k\">in</span> <span class=\"nv\">local_cities</span> <span class=\"cp\">%}</span>\n          <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">city.name</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">city.population</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n        <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>Note that <code class=\"docutils literal notranslate\">{% regroup %}</code> does not order its input! Our example relies on\nthe fact that the <code class=\"docutils literal notranslate\">cities</code> list was ordered by <code class=\"docutils literal notranslate\">country</code> in the first place.\nIf the <code class=\"docutils literal notranslate\">cities</code> list did <em>not</em> order its members by <code class=\"docutils literal notranslate\">country</code>, the\nregrouping would naively display more than one group for a single country. For\nexample, say the <code class=\"docutils literal notranslate\">cities</code> list was set to this (note that the countries are not\ngrouped together):</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code>cities <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Mumbai&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;19,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;India&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;New York&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;20,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;USA&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Calcutta&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;15,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;India&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Chicago&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;7,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;USA&quot;</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Tokyo&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;population&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;33,000,000&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;country&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Japan&quot;</span><span class=\"p\">},</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>Dengan masukan ini untuk <code class=\"docutils literal notranslate\">cities</code>, contoh kode cetakan <code class=\"docutils literal notranslate\">{% regroup %}</code> diatas akan menghasilkan keluaran berikut:</p>\n<ul class=\"simple\">\n<li><p>India</p>\n<ul>\n<li><p>Mumbai: 19,000,000</p></li>\n</ul>\n</li>\n<li><p>USA</p>\n<ul>\n<li><p>New York: 20,000,000</p></li>\n</ul>\n</li>\n<li><p>India</p>\n<ul>\n<li><p>Calcutta: 15,000,000</p></li>\n</ul>\n</li>\n<li><p>USA</p>\n<ul>\n<li><p>Chicago: 7,000,000</p></li>\n</ul>\n</li>\n<li><p>Jepang</p>\n<ul>\n<li><p>Tokyo: 33,000,000</p></li>\n</ul>\n</li>\n</ul>\n<p>The easiest solution to this gotcha is to make sure in your view code that the\ndata is ordered according to how you want to display it.</p>\n<p>Another solution is to sort the data in the template using the\n<a class=\"reference internal\" href=\"#std-templatefilter-dictsort\"><code class=\"xref std std-tfilter docutils literal notranslate\">dictsort</code></a> filter, if your data is in a list of dictionaries:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">regroup</span> <span class=\"nv\">cities</span><span class=\"o\">|</span><span class=\"nf\">dictsort</span><span class=\"s2\">:&quot;country&quot;</span> <span class=\"nv\">by</span> <span class=\"nv\">country</span> <span class=\"k\">as</span> <span class=\"nv\">country_list</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<section id=\"grouping-on-other-properties\">\n<h4>Mengkelompokkan pada sifat lain<a class=\"heading-anchor\" href=\"#grouping-on-other-properties\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Any valid template lookup is a legal grouping attribute for the regroup\ntag, including methods, attributes, dictionary keys and list items. For\nexample, if the &quot;country&quot; field is a foreign key to a class with\nan attribute &quot;description,&quot; you could use:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">regroup</span> <span class=\"nv\">cities</span> <span class=\"nv\">by</span> <span class=\"nv\">country.description</span> <span class=\"k\">as</span> <span class=\"nv\">country_list</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Or, if <code class=\"docutils literal notranslate\">country</code> is a field with <code class=\"docutils literal notranslate\">choices</code>, it will have a\n<a class=\"reference internal\" href=\"/id/5.0/ref/models/instances/#django.db.models.Model.get_FOO_display\" title=\"django.db.models.Model.get_FOO_display\"><code class=\"xref py py-meth docutils literal notranslate\">get_FOO_display()</code></a> method available as an\nattribute, allowing  you to group on the display string rather than the\n<code class=\"docutils literal notranslate\">choices</code> key:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">regroup</span> <span class=\"nv\">cities</span> <span class=\"nv\">by</span> <span class=\"nv\">get_country_display</span> <span class=\"k\">as</span> <span class=\"nv\">country_list</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p><code class=\"docutils literal notranslate\">{{ country.grouper }}</code> sekarang akan menampilan nilai bidang dari <code class=\"docutils literal notranslate\">choices</code> disetel daripada kunci.</p>\n</section>\n</section>\n<section id=\"resetcycle\">\n<span id=\"std-templatetag-resetcycle\"></span><h3><code class=\"docutils literal notranslate\">resetcycle</code><a class=\"heading-anchor\" href=\"#resetcycle\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Resets a previous <a class=\"reference internal\" href=\"#cycle\">cycle</a> so that it restarts from its first item at its next\nencounter. Without arguments, <code class=\"docutils literal notranslate\">{% resetcycle %}</code> will reset the last\n<code class=\"docutils literal notranslate\">{% cycle %}</code> defined in the template.</p>\n<p>Contoh penggunaan:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">coach</span> <span class=\"k\">in</span> <span class=\"nv\">coach_list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">coach.name</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">athlete</span> <span class=\"k\">in</span> <span class=\"nv\">coach.athlete_set.all</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">p</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;odd&#39;</span> <span class=\"s1\">&#39;even&#39;</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">athlete.name</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">resetcycle</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>This example would return this HTML:</p>\n<div class=\"code-block\" data-language=\"html\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Html</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Html code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>Gareth<span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;odd&quot;</span><span class=\"p\">&gt;</span>Harry<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;even&quot;</span><span class=\"p\">&gt;</span>John<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;odd&quot;</span><span class=\"p\">&gt;</span>Nick<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>John<span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;odd&quot;</span><span class=\"p\">&gt;</span>Andrea<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;even&quot;</span><span class=\"p\">&gt;</span>Melissa<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>Notice how the first block ends with <code class=\"docutils literal notranslate\">class=&quot;odd&quot;</code> and the new one starts\nwith <code class=\"docutils literal notranslate\">class=&quot;odd&quot;</code>. Without the <code class=\"docutils literal notranslate\">{% resetcycle %}</code> tag, the second block\nwould start with <code class=\"docutils literal notranslate\">class=&quot;even&quot;</code>.</p>\n<p>You can also reset named cycle tags:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">item</span> <span class=\"k\">in</span> <span class=\"nv\">list</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">p</span> <span class=\"na\">class</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;odd&#39;</span> <span class=\"s1\">&#39;even&#39;</span> <span class=\"k\">as</span> <span class=\"nv\">stripe</span> <span class=\"cp\">%}</span><span class=\"s\"> </span><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"s1\">&#39;major&#39;</span> <span class=\"s1\">&#39;minor&#39;</span> <span class=\"s1\">&#39;minor&#39;</span> <span class=\"s1\">&#39;minor&#39;</span> <span class=\"s1\">&#39;minor&#39;</span> <span class=\"k\">as</span> <span class=\"nv\">tick</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n        <span class=\"cp\">{{</span> <span class=\"nv\">item.data</span> <span class=\"cp\">}}</span>\n    <span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">ifchanged</span> <span class=\"nv\">item.category</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">item.category</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n        <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"k\">not</span> <span class=\"nb\">forloop</span><span class=\"nv\">.first</span> <span class=\"cp\">%}{%</span> <span class=\"k\">resetcycle</span> <span class=\"nv\">tick</span> <span class=\"cp\">%}{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endifchanged</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>In this example, we have both the alternating odd/even rows and a &quot;major&quot; row\nevery fifth row. Only the five-row cycle is reset when a category changes.</p>\n</section>\n<section id=\"spaceless\">\n<span id=\"std-templatetag-spaceless\"></span><h3><code class=\"docutils literal notranslate\">spaceless</code><a class=\"heading-anchor\" href=\"#spaceless\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Memindahkan ruang kosong diantara etiket HTML. Ini menyertakan karakter tab dan baris baru.</p>\n<p>Contoh penggunaan:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">spaceless</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">a</span> <span class=\"na\">href</span><span class=\"o\">=</span><span class=\"s\">&quot;foo/&quot;</span><span class=\"p\">&gt;</span>Foo<span class=\"p\">&lt;/</span><span class=\"nt\">a</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endspaceless</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>This example would return this HTML:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;&lt;</span><span class=\"nt\">a</span> <span class=\"na\">href</span><span class=\"o\">=</span><span class=\"s\">&quot;foo/&quot;</span><span class=\"p\">&gt;</span>Foo<span class=\"p\">&lt;/</span><span class=\"nt\">a</span><span class=\"p\">&gt;&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>Only space between <em>tags</em> is removed -- not space between tags and text. In\nthis example, the space around <code class=\"docutils literal notranslate\">Hello</code> won't be stripped:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">spaceless</span> <span class=\"cp\">%}</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">strong</span><span class=\"p\">&gt;</span>\n        Hello\n    <span class=\"p\">&lt;/</span><span class=\"nt\">strong</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endspaceless</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"templatetag\">\n<span id=\"std-templatetag-templatetag\"></span><h3><code class=\"docutils literal notranslate\">templatetag</code><a class=\"heading-anchor\" href=\"#templatetag\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Outputs one of the syntax characters used to compose template tags.</p>\n<p>The template system has no concept of &quot;escaping&quot; individual characters.\nHowever, you can use the <code class=\"docutils literal notranslate\">{% templatetag %}</code> tag to display one of the\ntemplate tag character combinations.</p>\n<p>Argumen akan memberitahu bit cetakan mana akan keluar:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Argument</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">openblock</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{%</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">closeblock</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">%}</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">openvariable</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">closevariable</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">}}</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">openbrace</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">closebrace</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">}</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">opencomment</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{#</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">closecomment</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">#}</code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Sample usage:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>The <span class=\"cp\">{%</span> <span class=\"k\">templatetag</span> <span class=\"nv\">openblock</span> <span class=\"cp\">%}</span> characters open a block.\n</code></pre></div>\n<p>See also the <a class=\"reference internal\" href=\"#std-templatetag-verbatim\"><code class=\"xref std std-ttag docutils literal notranslate\">verbatim</code></a> tag for another way of including these\ncharacters.</p>\n</section>\n<section id=\"url\">\n<span id=\"std-templatetag-url\"></span><h3><code class=\"docutils literal notranslate\">url</code><a class=\"heading-anchor\" href=\"#url\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Returns an absolute path reference (a URL without the domain name) matching a\ngiven view and optional parameters. Any special characters in the resulting\npath will be encoded using <a class=\"reference internal\" href=\"/id/5.0/ref/utils/#django.utils.encoding.iri_to_uri\" title=\"django.utils.encoding.iri_to_uri\"><code class=\"xref py py-func docutils literal notranslate\">iri_to_uri()</code></a>.</p>\n<p>This is a way to output links without violating the DRY principle by having to\nhard-code URLs in your templates:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">url</span> <span class=\"s1\">&#39;some-url-name&#39;</span> <span class=\"nv\">v1</span> <span class=\"nv\">v2</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>The first argument is a <a class=\"reference internal\" href=\"/id/5.0/topics/http/urls/#naming-url-patterns\"><span class=\"std std-ref\">URL pattern name</span></a>. It can\nbe a quoted literal or any other context variable. Additional arguments are\noptional and should be space-separated values that will be used as arguments in\nthe URL. The example above shows passing positional arguments. Alternatively\nyou may use keyword syntax:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">url</span> <span class=\"s1\">&#39;some-url-name&#39;</span> <span class=\"nv\">arg1</span><span class=\"o\">=</span><span class=\"nv\">v1</span> <span class=\"nv\">arg2</span><span class=\"o\">=</span><span class=\"nv\">v2</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Do not mix both positional and keyword syntax in a single call. All arguments\nrequired by the URLconf should be present.</p>\n<p>For example, suppose you have a view, <code class=\"docutils literal notranslate\">app_views.client</code>, whose URLconf\ntakes a client ID (here, <code class=\"docutils literal notranslate\">client()</code> is a method inside the views file\n<code class=\"docutils literal notranslate\">app_views.py</code>). The URLconf line might look like this:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code>path<span class=\"p\">(</span><span class=\"s2\">&quot;client/&lt;int:id&gt;/&quot;</span><span class=\"p\">,</span> app_views<span class=\"o\">.</span>client<span class=\"p\">,</span> name<span class=\"o\">=</span><span class=\"s2\">&quot;app-views-client&quot;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>If this app's URLconf is included into the project's URLconf under a path\nsuch as this:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code>path<span class=\"p\">(</span><span class=\"s2\">&quot;clients/&quot;</span><span class=\"p\">,</span> include<span class=\"p\">(</span><span class=\"s2\">&quot;project_name.app_name.urls&quot;</span><span class=\"p\">))</span>\n</code></pre></div>\n<p>...then, in a template, you can create a link to this view like this:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">url</span> <span class=\"s1\">&#39;app-views-client&#39;</span> <span class=\"nv\">client.id</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Etiket cetakan akan mengeluarkan deretan karakter <code class=\"docutils literal notranslate\">/clients/client/123/</code>.</p>\n<p>Note that if the URL you're reversing doesn't exist, you'll get an\n<a class=\"reference internal\" href=\"/id/5.0/ref/exceptions/#django.urls.NoReverseMatch\" title=\"django.urls.NoReverseMatch\"><code class=\"xref py py-exc docutils literal notranslate\">NoReverseMatch</code></a> exception raised, which will cause your\nsite to display an error page.</p>\n<p>If you'd like to retrieve a URL without displaying it, you can use a slightly\ndifferent call:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">url</span> <span class=\"s1\">&#39;some-url-name&#39;</span> <span class=\"nv\">arg</span> <span class=\"nv\">arg2</span> <span class=\"k\">as</span> <span class=\"nv\">the_url</span> <span class=\"cp\">%}</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">a</span> <span class=\"na\">href</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">the_url</span> <span class=\"cp\">}}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>I&#39;m linking to <span class=\"cp\">{{</span> <span class=\"nv\">the_url</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">a</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>The scope of the variable created by the  <code class=\"docutils literal notranslate\">as var</code> syntax is the\n<code class=\"docutils literal notranslate\">{% block %}</code> in which the <code class=\"docutils literal notranslate\">{% url %}</code> tag appears.</p>\n<p>This <code class=\"docutils literal notranslate\">{% url ... as var %}</code> syntax will <em>not</em> cause an error if the view is\nmissing. In practice you'll use this to link to views that are optional:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">url</span> <span class=\"s1\">&#39;some-url-name&#39;</span> <span class=\"k\">as</span> <span class=\"nv\">the_url</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">the_url</span> <span class=\"cp\">%}</span>\n  <span class=\"p\">&lt;</span><span class=\"nt\">a</span> <span class=\"na\">href</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">the_url</span> <span class=\"cp\">}}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>Link to optional stuff<span class=\"p\">&lt;/</span><span class=\"nt\">a</span><span class=\"p\">&gt;</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>If you'd like to retrieve a namespaced URL, specify the fully qualified name:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">url</span> <span class=\"s1\">&#39;myapp:view-name&#39;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>This will follow the normal <a class=\"reference internal\" href=\"/id/5.0/topics/http/urls/#topics-http-reversing-url-namespaces\"><span class=\"std std-ref\">namespaced URL resolution strategy</span></a>, including using any hints provided\nby the context as to the current application.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Peringatan</p>\n<p>Don't forget to put quotes around the URL pattern <code class=\"docutils literal notranslate\">name</code>, otherwise the\nvalue will be interpreted as a context variable!</p>\n</aside>\n</section>\n<section id=\"verbatim\">\n<span id=\"std-templatetag-verbatim\"></span><h3><code class=\"docutils literal notranslate\">verbatim</code><a class=\"heading-anchor\" href=\"#verbatim\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Stops the template engine from rendering the contents of this block tag.</p>\n<p>A common use is to allow a JavaScript template layer that collides with\nDjango's syntax. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">verbatim</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span><span class=\"k\">if</span> <span class=\"nv\">dying</span><span class=\"cp\">}}</span>Still alive.<span class=\"cp\">{{</span><span class=\"o\">/</span><span class=\"k\">if</span><span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endverbatim</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>You can also designate a specific closing tag, allowing the use of\n<code class=\"docutils literal notranslate\">{% endverbatim %}</code> as part of the unrendered contents:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">verbatim</span> <span class=\"nv\">myblock</span> <span class=\"cp\">%}</span>\n    Avoid template rendering via the <span class=\"cp\">{%</span> <span class=\"k\">verbatim</span> <span class=\"cp\">%}{%</span> <span class=\"k\">endverbatim</span> <span class=\"cp\">%}</span> block.\n<span class=\"cp\">{%</span> <span class=\"k\">endverbatim</span> <span class=\"nv\">myblock</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"widthratio\">\n<span id=\"std-templatetag-widthratio\"></span><h3><code class=\"docutils literal notranslate\">widthratio</code><a class=\"heading-anchor\" href=\"#widthratio\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>For creating bar charts and such, this tag calculates the ratio of a given\nvalue to a maximum value, and then applies that ratio to a constant.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">img</span> <span class=\"na\">src</span><span class=\"o\">=</span><span class=\"s\">&quot;bar.png&quot;</span> <span class=\"na\">alt</span><span class=\"o\">=</span><span class=\"s\">&quot;Bar&quot;</span>\n     <span class=\"na\">height</span><span class=\"o\">=</span><span class=\"s\">&quot;10&quot;</span> <span class=\"na\">width</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">widthratio</span> <span class=\"nv\">this_value</span> <span class=\"nv\">max_value</span> <span class=\"nv\">max_width</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">this_value</code> is 175, <code class=\"docutils literal notranslate\">max_value</code> is 200, and <code class=\"docutils literal notranslate\">max_width</code> is 100, the\nimage in the above example will be 88 pixels wide\n(because 175/200 = .875; .875 * 100 = 87.5 which is rounded up to 88).</p>\n<p>In some cases you might want to capture the result of <code class=\"docutils literal notranslate\">widthratio</code> in a\nvariable. It can be useful, for instance, in a <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/translation/#std-templatetag-blocktranslate\"><code class=\"xref std std-ttag docutils literal notranslate\">blocktranslate</code></a> like this:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">widthratio</span> <span class=\"nv\">this_value</span> <span class=\"nv\">max_value</span> <span class=\"nv\">max_width</span> <span class=\"k\">as</span> <span class=\"nv\">width</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">blocktranslate</span> <span class=\"cp\">%}</span>The width is: <span class=\"cp\">{{</span> <span class=\"nv\">width</span> <span class=\"cp\">}}{%</span> <span class=\"k\">endblocktranslate</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"with\">\n<span id=\"std-templatetag-with\"></span><h3><code class=\"docutils literal notranslate\">with</code><a class=\"heading-anchor\" href=\"#with\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Caches a complex variable under a simpler name. This is useful when accessing\nan &quot;expensive&quot; method (e.g., one that hits the database) multiple times.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">with</span> <span class=\"nv\">total</span><span class=\"o\">=</span><span class=\"nv\">business.employees.count</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">total</span> <span class=\"cp\">}}</span> employee<span class=\"cp\">{{</span> <span class=\"nv\">total</span><span class=\"o\">|</span><span class=\"nf\">pluralize</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endwith</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>The populated variable (in the example above, <code class=\"docutils literal notranslate\">total</code>) is only available\nbetween the <code class=\"docutils literal notranslate\">{% with %}</code> and <code class=\"docutils literal notranslate\">{% endwith %}</code> tags.</p>\n<p>You can assign more than one context variable:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">with</span> <span class=\"nv\">alpha</span><span class=\"o\">=</span><span class=\"m\">1</span> <span class=\"nv\">beta</span><span class=\"o\">=</span><span class=\"m\">2</span> <span class=\"cp\">%}</span>\n    ...\n<span class=\"cp\">{%</span> <span class=\"k\">endwith</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>The previous more verbose format is still supported:\n<code class=\"docutils literal notranslate\">{% with business.employees.count as total %}</code></p>\n</aside>\n</section>\n</section>\n<section id=\"built-in-filter-reference\">\n<span id=\"ref-templates-builtins-filters\"></span><h2>Petunjuk penyaring siap-pakai<a class=\"heading-anchor\" href=\"#built-in-filter-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"add\">\n<span id=\"std-templatefilter-add\"></span><h3><code class=\"docutils literal notranslate\">add</code><a class=\"heading-anchor\" href=\"#add\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Tambah argumen ke nilai.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">add</span><span class=\"s2\">:&quot;2&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">4</code>, kemudian keluaran akan menjadi <code class=\"docutils literal notranslate\">6</code>.</p>\n<p>This filter will first try to coerce both values to integers. If this fails,\nit'll attempt to add the values together anyway. This will work on some data\ntypes (strings, list, etc.) and fail on others. If it fails, the result will\nbe an empty string.</p>\n<p>For example, if we have:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">first</span><span class=\"o\">|</span><span class=\"nf\">add</span><span class=\"o\">:</span><span class=\"nv\">second</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>dan <code class=\"docutils literal notranslate\">first</code> adalah <code class=\"docutils literal notranslate\">[1, 2, 3]</code> dan <code class=\"docutils literal notranslate\">second</code> adalah <code class=\"docutils literal notranslate\">[4, 5, 6]</code>, kemudian keluaran akan berupa <code class=\"docutils literal notranslate\">[1, 2, 3, 4, 5, 6]</code>.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Peringatan</p>\n<p>Strings that can be coerced to integers will be <strong>summed</strong>, not\nconcatenated, as in the first example above.</p>\n</aside>\n</section>\n<section id=\"addslashes\">\n<span id=\"std-templatefilter-addslashes\"></span><h3><code class=\"docutils literal notranslate\">addslashes</code><a class=\"heading-anchor\" href=\"#addslashes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Tambah garis miring sebelum kutipan. Berguna untuk pelolosan string dalam CSV, sebagai contoh.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">addslashes</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;I'm using Django&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;I\\'m using Django&quot;</code>.</p>\n</section>\n<section id=\"capfirst\">\n<span id=\"std-templatefilter-capfirst\"></span><h3><code class=\"docutils literal notranslate\">capfirst</code><a class=\"heading-anchor\" href=\"#capfirst\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Capitalizes the first character of the value. If the first character is not\na letter, this filter has no effect.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">capfirst</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;django&quot;</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">&quot;Django&quot;</code>.</p>\n</section>\n<section id=\"center\">\n<span id=\"std-templatefilter-center\"></span><h3><code class=\"docutils literal notranslate\">center</code><a class=\"heading-anchor\" href=\"#center\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Tengahkan nilai di bidang dari lebar yang diberikan.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>&quot;<span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">center</span><span class=\"s2\">:&quot;15&quot;</span> <span class=\"cp\">}}</span>&quot;\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;Django&quot;</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">&quot; Django &quot;</code>.</p>\n</section>\n<section id=\"cut\">\n<span id=\"std-templatefilter-cut\"></span><h3><code class=\"docutils literal notranslate\">cut</code><a class=\"heading-anchor\" href=\"#cut\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Memindahkan semua nilai dari arg dari string yang diberikan.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">cut</span><span class=\"s2\">:&quot; &quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;String with spaces&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;Stringwithspaces&quot;</code>.</p>\n</section>\n<section id=\"date\">\n<span id=\"std-templatefilter-date\"></span><h3><code class=\"docutils literal notranslate\">date</code><a class=\"heading-anchor\" href=\"#date\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Bentuk tanggal menurut pada bentuk yang diberikan.</p>\n<p>Uses a similar format to PHP's <a class=\"reference external\" href=\"https://www.php.net/manual/en/function.date.php\">date()</a> function with some\ndifferences.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>These format characters are not used in Django outside of templates. They\nwere designed to be compatible with PHP to ease transitioning for designers.</p>\n</aside>\n<p id=\"date-and-time-formatting-specifiers\">String bentuk tersedia:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Bentuk karakter</p></th>\n<th class=\"head\"><p>Deskripsi</p></th>\n<th class=\"head\"><p>Contoh keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><strong>Hari</strong></p></td>\n<td></td>\n<td></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">d</code></p></td>\n<td><p>Hari dari bulan, 2 angka dengan dimulai nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'01'</code> sampai <code class=\"docutils literal notranslate\">'31'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">j</code></p></td>\n<td><p>Hari dari bulan tanpa dimulai nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'1'</code> sampai <code class=\"docutils literal notranslate\">'31'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">D</code></p></td>\n<td><p>Hari dari minggu, tekstual, 3 huruf.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'Fri'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">l</code></p></td>\n<td><p>Hari dari minggu, tekstual, panjang.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'Jumat'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">S</code></p></td>\n<td><p>English ordinal suffix for day of the\nmonth, 2 characters.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'st'</code>, <code class=\"docutils literal notranslate\">'nd'</code>, <code class=\"docutils literal notranslate\">'rd'</code> or <code class=\"docutils literal notranslate\">'th'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">w</code></p></td>\n<td><p>Hari dari minggu, angka tanpa dimulai nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'0'</code> (Minggu) sampai <code class=\"docutils literal notranslate\">'6'</code> (Sabtu)</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">z</code></p></td>\n<td><p>Hari dari tahun.</p></td>\n<td><p><code class=\"docutils literal notranslate\">1</code> to <code class=\"docutils literal notranslate\">366</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><strong>Minggu</strong></p></td>\n<td></td>\n<td></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">W</code></p></td>\n<td><p>Angka minggu ISO-8601 dari tahun, dengan minggu dimulai pada Senin.</p></td>\n<td><p><code class=\"docutils literal notranslate\">1</code>, <code class=\"docutils literal notranslate\">53</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><strong>Bulan</strong></p></td>\n<td></td>\n<td></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">m</code></p></td>\n<td><p>Bulan, 2 angka tanpa dimulai nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'01'</code> sampai <code class=\"docutils literal notranslate\">'12'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">n</code></p></td>\n<td><p>Bulan tanpa dimulai dengan nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'1'</code> sampai <code class=\"docutils literal notranslate\">'12'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">M</code></p></td>\n<td><p>Bulan, tektual, 3 huruf.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'Jan'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">b</code></p></td>\n<td><p>Bulan, tekstual, 3 huruf, huruf kecil.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'jan'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">E</code></p></td>\n<td><p>Month, locale specific alternative\nrepresentation usually used for long\ndate representation.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'listopada'</code> (untuk lokal Polandia, sebagai lawan terhadap <code class=\"docutils literal notranslate\">'Listopad'</code>)</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">F</code></p></td>\n<td><p>Bulan, tektual, panjang.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'Januari'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">N</code></p></td>\n<td><p>Month abbreviation in Associated Press\nstyle. Proprietary extension.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'Jan.'</code>, <code class=\"docutils literal notranslate\">'Feb.'</code>, <code class=\"docutils literal notranslate\">'Maret'</code>, <code class=\"docutils literal notranslate\">'Mei'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">t</code></p></td>\n<td><p>Jumlah hari dalam bulan yang diberikan.</p></td>\n<td><p><code class=\"docutils literal notranslate\">28</code> sampai <code class=\"docutils literal notranslate\">31</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><strong>Tahun</strong></p></td>\n<td></td>\n<td></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">y</code></p></td>\n<td><p>Year, 2 digits with leading zeros.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'00'</code> to <code class=\"docutils literal notranslate\">'99'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">Y</code></p></td>\n<td><p>Year, 4 digits with leading zeros.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'0001'</code>, ..., <code class=\"docutils literal notranslate\">'1999'</code>, ..., <code class=\"docutils literal notranslate\">'9999'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">L</code></p></td>\n<td><p>Boolean untuk apakah itu adalah tahun kabisat.</p></td>\n<td><p><code class=\"docutils literal notranslate\">True</code> atau <code class=\"docutils literal notranslate\">False</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">o</code></p></td>\n<td><p>ISO-8601 week-numbering year,\ncorresponding to the ISO-8601 week\nnumber (W) which uses leap weeks. See Y\nfor the more common year format.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'1999'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><strong>Waktu</strong></p></td>\n<td></td>\n<td></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">g</code></p></td>\n<td><p>Jam, bentuk 12-jam tanpa diawali nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'1'</code> sampai <code class=\"docutils literal notranslate\">'12'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">G</code></p></td>\n<td><p>Jam, bentuk 24-jam tanpa diawali nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'0'</code> sampai <code class=\"docutils literal notranslate\">'23'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">h</code></p></td>\n<td><p>Jam, bentuk 12-jam.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'01'</code> sampai <code class=\"docutils literal notranslate\">'12'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">H</code></p></td>\n<td><p>Jam, bentuk 24-jam.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'00'</code> sampai <code class=\"docutils literal notranslate\">'23'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">i</code></p></td>\n<td><p>Menit.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'00'</code> sampai <code class=\"docutils literal notranslate\">'59'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">s</code></p></td>\n<td><p>Dua, 2 angka dengan awal nol.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'00'</code> sampai <code class=\"docutils literal notranslate\">'59'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">u</code></p></td>\n<td><p>Mikrodetik</p></td>\n<td><p><code class=\"docutils literal notranslate\">000000</code> sampai <code class=\"docutils literal notranslate\">999999</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">a</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">'a.m.'</code> or <code class=\"docutils literal notranslate\">'p.m.'</code> (Note that\nthis is slightly different than PHP's\noutput, because this includes periods\nto match Associated Press style.)</p></td>\n<td><p><code class=\"docutils literal notranslate\">'a.m.'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">A</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">'AM'</code> atau <code class=\"docutils literal notranslate\">'PM'</code>.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'AM'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">f</code></p></td>\n<td><p>Time, in 12-hour hours and minutes,\nwith minutes left off if they're zero.\nProprietary extension.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'1'</code>, <code class=\"docutils literal notranslate\">'1:30'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">P</code></p></td>\n<td><p>Time, in 12-hour hours, minutes and\n'a.m.'/'p.m.', with minutes left off\nif they're zero and the special-case\nstrings 'midnight' and 'noon' if\nappropriate. Proprietary extension.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'1 a.m.'</code>, <code class=\"docutils literal notranslate\">'1:30 p.m.'</code>, <code class=\"docutils literal notranslate\">'midnight'</code>, <code class=\"docutils literal notranslate\">'noon'</code>, <code class=\"docutils literal notranslate\">'12:30 p.m.'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><strong>Zona waktu</strong></p></td>\n<td></td>\n<td></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">e</code></p></td>\n<td><p>Timezone name. Could be in any format,\nor might return an empty string,\ndepending on the datetime.</p></td>\n<td><p><code class=\"docutils literal notranslate\">''</code>, <code class=\"docutils literal notranslate\">'GMT'</code>, <code class=\"docutils literal notranslate\">'-500'</code>, <code class=\"docutils literal notranslate\">'US/Eastern'</code>, etc.</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">I</code></p></td>\n<td><p>Daylight saving time, whether it's in\neffect or not.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'1'</code> atau <code class=\"docutils literal notranslate\">'0'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">O</code></p></td>\n<td><p>Perbedaan pada waktu Greenwich dalam jam.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'+0200'</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">T</code></p></td>\n<td><p>Zona waktu dari mesin ini.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'EST'</code>, <code class=\"docutils literal notranslate\">'MDT'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">Z</code></p></td>\n<td><p>Time zone offset in seconds. The\noffset for timezones west of UTC is\nalways negative, and for those east of\nUTC is always positive.</p></td>\n<td><p><code class=\"docutils literal notranslate\">-43200</code> sampai <code class=\"docutils literal notranslate\">43200</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><strong>Tanggal/Waktu</strong></p></td>\n<td></td>\n<td></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">c</code></p></td>\n<td><p>ISO 8601 format. (Note: unlike other\nformatters, such as &quot;Z&quot;, &quot;O&quot; or &quot;r&quot;,\nthe &quot;c&quot; formatter will not add timezone\noffset if value is a naive datetime\n(see <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.tzinfo\" title=\"(di Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime.tzinfo</code></a>).</p></td>\n<td><p><code class=\"docutils literal notranslate\">2008-01-02T10:30:00.000123+02:00</code>, atau <code class=\"docutils literal notranslate\">2008-01-02T10:30:00.000123</code> jika datetime tidak dibuat-buat</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">r</code></p></td>\n<td><p><span class=\"target\" id=\"index-0\"></span><a class=\"rfc reference external\" href=\"https://datatracker.ietf.org/doc/html/rfc5322.html#section-3.3\"><strong>RFC 5322</strong></a>\nformatted date.</p></td>\n<td><p><code class=\"docutils literal notranslate\">'Kam, 21 Des 2000 16:01:07 +0200'</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">U</code></p></td>\n<td><p>Dua sejak Unix Epoch (January 1 1970 00:00:00 UTC).</p></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;D d M Y&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">value</code> is a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(di Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a> object (e.g., the result of\n<code class=\"docutils literal notranslate\">datetime.datetime.now()</code>), the output will be the string\n<code class=\"docutils literal notranslate\">'Wed 09 Jan 2008'</code>.</p>\n<p>The format passed can be one of the predefined ones <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-DATE_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">DATE_FORMAT</code></a>,\n<a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-DATETIME_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">DATETIME_FORMAT</code></a>, <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-SHORT_DATE_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">SHORT_DATE_FORMAT</code></a> or\n<a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-SHORT_DATETIME_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">SHORT_DATETIME_FORMAT</code></a>, or a custom format that uses the format\nspecifiers shown in the table above. Note that predefined formats may vary\ndepending on the current locale.</p>\n<p>Assuming that <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-LANGUAGE_CODE\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGE_CODE</code></a> is, for example, <code class=\"docutils literal notranslate\">&quot;es&quot;</code>, then for:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;SHORT_DATE_FORMAT&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>the output would be the string <code class=\"docutils literal notranslate\">&quot;09/01/2008&quot;</code> (the <code class=\"docutils literal notranslate\">&quot;SHORT_DATE_FORMAT&quot;</code>\nformat specifier for the <code class=\"docutils literal notranslate\">es</code> locale as shipped with Django is <code class=\"docutils literal notranslate\">&quot;d/m/Y&quot;</code>).</p>\n<p>When used without a format string, the <code class=\"docutils literal notranslate\">DATE_FORMAT</code> format specifier is\nused. Assuming the same settings as the previous example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">date</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>outputs <code class=\"docutils literal notranslate\">9 de Enero de 2008</code> (the <code class=\"docutils literal notranslate\">DATE_FORMAT</code> format specifier for the\n<code class=\"docutils literal notranslate\">es</code> locale is <code class=\"docutils literal notranslate\">r'j \\d\\e F \\d\\e Y'</code>). Both &quot;d&quot; and &quot;e&quot; are\nbackslash-escaped, because otherwise each is a format string that displays the\nday and the timezone name, respectively.</p>\n<p>You can combine <code class=\"docutils literal notranslate\">date</code> with the <a class=\"reference internal\" href=\"#std-templatefilter-time\"><code class=\"xref std std-tfilter docutils literal notranslate\">time</code></a> filter to render a full\nrepresentation of a <code class=\"docutils literal notranslate\">datetime</code> value. E.g.:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;D d M Y&quot;</span> <span class=\"cp\">}}</span> <span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">time</span><span class=\"s2\">:&quot;H:i&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n</section>\n<section id=\"default\">\n<span id=\"std-templatefilter-default\"></span><h3><code class=\"docutils literal notranslate\">default</code><a class=\"heading-anchor\" href=\"#default\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Jika nilai dinilai ke <code class=\"docutils literal notranslate\">False</code>, gunakan awal yang diberikan. Sebaliknya, gunakan nilai.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">default</span><span class=\"s2\">:&quot;nothing&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;&quot;</code> (string kosong), keluaran akan berupa <code class=\"docutils literal notranslate\">nothing</code>.</p>\n</section>\n<section id=\"default-if-none\">\n<span id=\"std-templatefilter-default_if_none\"></span><h3><code class=\"docutils literal notranslate\">default_if_none</code><a class=\"heading-anchor\" href=\"#default-if-none\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Jika (dan hanya jika) nilai adalah <code class=\"docutils literal notranslate\">None</code>, gunakan awal yang diberikan. Sebaliknya, gunakan nilai.</p>\n<p>Note that if an empty string is given, the default value will <em>not</em> be used.\nUse the <a class=\"reference internal\" href=\"#std-templatefilter-default\"><code class=\"xref std std-tfilter docutils literal notranslate\">default</code></a> filter if you want to fallback for empty strings.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">default_if_none</span><span class=\"s2\">:&quot;nothing&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">None</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">nothing</code>.</p>\n</section>\n<section id=\"dictsort\">\n<span id=\"std-templatefilter-dictsort\"></span><h3><code class=\"docutils literal notranslate\">dictsort</code><a class=\"heading-anchor\" href=\"#dictsort\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Takes a list of dictionaries and returns that list sorted by the key given in\nthe argument.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">dictsort</span><span class=\"s2\">:&quot;name&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"p\">[</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;zed&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">19</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;amy&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">22</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;joe&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">31</span><span class=\"p\">},</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>kemudian keluarannya akan menjadi:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"p\">[</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;amy&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">22</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;joe&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">31</span><span class=\"p\">},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;zed&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">19</span><span class=\"p\">},</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>You can also do more complicated things like:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">book</span> <span class=\"k\">in</span> <span class=\"nv\">books</span><span class=\"o\">|</span><span class=\"nf\">dictsort</span><span class=\"s2\">:&quot;author.age&quot;</span> <span class=\"cp\">%}</span>\n    * <span class=\"cp\">{{</span> <span class=\"nv\">book.title</span> <span class=\"cp\">}}</span> (<span class=\"cp\">{{</span> <span class=\"nv\">book.author.name</span> <span class=\"cp\">}}</span>)\n<span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">books</code> adalah:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"p\">[</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;title&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;1984&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;author&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;George&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">45</span><span class=\"p\">}},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;title&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Timequake&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;author&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Kurt&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">75</span><span class=\"p\">}},</span>\n    <span class=\"p\">{</span><span class=\"s2\">&quot;title&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Alice&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;author&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;Lewis&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;age&quot;</span><span class=\"p\">:</span> <span class=\"mi\">33</span><span class=\"p\">}},</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>kemudian keluarannya akan menjadi:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>* Alice (Lewis)\n* 1984 (George)\n* Timequake (Kurt)\n</code></pre></div>\n<p><code class=\"docutils literal notranslate\">dictsort</code> can also order a list of lists (or any other object implementing\n<code class=\"docutils literal notranslate\">__getitem__()</code>) by elements at specified index. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">dictsort</span><span class=\"o\">:</span><span class=\"m\">0</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"p\">[</span>\n    <span class=\"p\">(</span><span class=\"s2\">&quot;a&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;42&quot;</span><span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s2\">&quot;c&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;string&quot;</span><span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s2\">&quot;b&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;foo&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>kemudian keluarannya akan menjadi:</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"p\">[</span>\n    <span class=\"p\">(</span><span class=\"s2\">&quot;a&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;42&quot;</span><span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s2\">&quot;b&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;foo&quot;</span><span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s2\">&quot;c&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;string&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>You must pass the index as an integer rather than a string. The following\nproduce empty output:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">values</span><span class=\"o\">|</span><span class=\"nf\">dictsort</span><span class=\"s2\">:&quot;0&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Ordering by elements at specified index is not supported on dictionaries.</p>\n<aside class=\"version-note version-changed\" data-version=\"2.2.26\" role=\"note\">\n<p class=\"version-note-title\">Changed in Django 2.2.26</p><p>In older versions, ordering elements at specified index was supported on\ndictionaries.</p>\n</aside>\n</section>\n<section id=\"dictsortreversed\">\n<span id=\"std-templatefilter-dictsortreversed\"></span><h3><code class=\"docutils literal notranslate\">dictsortreversed</code><a class=\"heading-anchor\" href=\"#dictsortreversed\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Takes a list of dictionaries and returns that list sorted in reverse order by\nthe key given in the argument. This works exactly the same as the above filter,\nbut the returned value will be in reverse order.</p>\n</section>\n<section id=\"divisibleby\">\n<span id=\"std-templatefilter-divisibleby\"></span><h3><code class=\"docutils literal notranslate\">divisibleby</code><a class=\"heading-anchor\" href=\"#divisibleby\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Mengembalikan <code class=\"docutils literal notranslate\">True</code> jika nilai terbagi oleh argumen.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">divisibleby</span><span class=\"s2\">:&quot;3&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">21</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">True</code>.</p>\n</section>\n<section id=\"escape\">\n<span id=\"std-templatefilter-escape\"></span><h3><code class=\"docutils literal notranslate\">escape</code><a class=\"heading-anchor\" href=\"#escape\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Meloloskan HTML string. Khususnya, itu membuat pergantian ini:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">&lt;</code> dirubah ke <code class=\"docutils literal notranslate\">&amp;lt;</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">&gt;</code> dirubah ke <code class=\"docutils literal notranslate\">&amp;gt;</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">'</code> (single quote) is converted to <code class=\"docutils literal notranslate\">&amp;#x27;</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">&quot;</code> (kutip ganda) dirubah ke <code class=\"docutils literal notranslate\">&amp;quot;</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">&amp;</code> dirubah ke <code class=\"docutils literal notranslate\">&amp;amp;</code></p></li>\n</ul>\n<p>Applying <code class=\"docutils literal notranslate\">escape</code> to a variable that would normally have auto-escaping\napplied to the result will only result in one round of escaping being done. So\nit is safe to use this function even in auto-escaping environments. If you want\nmultiple escaping passes to be applied, use the <a class=\"reference internal\" href=\"#std-templatefilter-force_escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">force_escape</code></a> filter.</p>\n<p>For example, you can apply <code class=\"docutils literal notranslate\">escape</code> to fields when <a class=\"reference internal\" href=\"#std-templatetag-autoescape\"><code class=\"xref std std-ttag docutils literal notranslate\">autoescape</code></a> is off:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">off</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">title</span><span class=\"o\">|</span><span class=\"nf\">escape</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<aside class=\"admonition-chaining-escape-with-other-filters admonition\" role=\"note\">\n<p class=\"admonition-title\">Chaining <code class=\"docutils literal notranslate\">escape</code> with other filters</p>\n<p>As mentioned in the <a class=\"reference internal\" href=\"#std-templatetag-autoescape\"><code class=\"xref std std-ttag docutils literal notranslate\">autoescape</code></a> section, when filters including\n<code class=\"docutils literal notranslate\">escape</code> are chained together, it can result in unexpected outcomes if\npreceding filters mark a potentially unsafe string as safe due to the lack\nof escaping caused by <a class=\"reference internal\" href=\"#std-templatetag-autoescape\"><code class=\"xref std std-ttag docutils literal notranslate\">autoescape</code></a> being <code class=\"docutils literal notranslate\">off</code>.</p>\n<p>In such cases, chaining <code class=\"docutils literal notranslate\">escape</code> would not reescape strings that have\nalready been marked as safe.</p>\n<p>This is especially important when using filters that operate on sequences,\nfor example <a class=\"reference internal\" href=\"#std-templatefilter-join\"><code class=\"xref std std-tfilter docutils literal notranslate\">join</code></a>. If you need to escape each element in a\nsequence, use the dedicated <a class=\"reference internal\" href=\"#std-templatefilter-escapeseq\"><code class=\"xref std std-tfilter docutils literal notranslate\">escapeseq</code></a> filter.</p>\n</aside>\n</section>\n<section id=\"escapejs\">\n<span id=\"std-templatefilter-escapejs\"></span><h3><code class=\"docutils literal notranslate\">escapejs</code><a class=\"heading-anchor\" href=\"#escapejs\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Escapes characters for use as a whole JavaScript string literal, within single\nor double quotes, as below. This filter does not make the string safe for use\nin <em>&quot;JavaScript template literals&quot;</em> (the JavaScript backtick syntax). Any other\nuses not listed above are not supported. It is generally recommended that data\nshould be passed using HTML <code class=\"docutils literal notranslate\">data-</code> attributes, or the <a class=\"reference internal\" href=\"#std-templatefilter-json_script\"><code class=\"xref std std-tfilter docutils literal notranslate\">json_script</code></a>\nfilter, rather than in embedded JavaScript.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">script</span><span class=\"p\">&gt;</span>\n<span class=\"kd\">let</span> <span class=\"nx\">myValue</span> <span class=\"o\">=</span> <span class=\"s1\">&#39;</span><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">escapejs</span> <span class=\"cp\">}}</span><span class=\"s1\">&#39;</span>\n</code></pre></div>\n</section>\n<section id=\"escapeseq\">\n<span id=\"std-templatefilter-escapeseq\"></span><h3><code class=\"docutils literal notranslate\">escapeseq</code><a class=\"heading-anchor\" href=\"#escapeseq\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<aside class=\"version-note version-added\" data-version=\"5.0\" role=\"note\">\n<p class=\"version-note-title\">New in Django 5.0</p></aside>\n<p>Applies the <a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> filter to each element of a sequence. Useful in\nconjunction with other filters that operate on sequences, such as\n<a class=\"reference internal\" href=\"#std-templatefilter-join\"><code class=\"xref std std-tfilter docutils literal notranslate\">join</code></a>. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">off</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">my_list</span><span class=\"o\">|</span><span class=\"nf\">escapeseq</span><span class=\"o\">|</span><span class=\"nf\">join</span><span class=\"s2\">:&quot;, &quot;</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"filesizeformat\">\n<span id=\"std-templatefilter-filesizeformat\"></span><h3><code class=\"docutils literal notranslate\">filesizeformat</code><a class=\"heading-anchor\" href=\"#filesizeformat\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>membentuk nilai seperti ukuran berkas 'dapat-dibaca-manusia' (yaitu <code class=\"docutils literal notranslate\">'13 KB'</code>, <code class=\"docutils literal notranslate\">'4.1 MB'</code>, <code class=\"docutils literal notranslate\">'102 bytes'</code>, dll.).</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">filesizeformat</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah 123456789, keluaran akan berupa <code class=\"docutils literal notranslate\">117.7 MB</code>.</p>\n<aside class=\"admonition-file-sizes-and-si-units admonition\" role=\"note\">\n<p class=\"admonition-title\">Ukuran berkas dan satuan SI</p>\n<p>Strictly speaking, <code class=\"docutils literal notranslate\">filesizeformat</code> does not conform to the International\nSystem of Units which recommends using KiB, MiB, GiB, etc. when byte sizes\nare calculated in powers of 1024 (which is the case here). Instead, Django\nuses traditional unit names (KB, MB, GB, etc.) corresponding to names that\nare more commonly used.</p>\n</aside>\n</section>\n<section id=\"first\">\n<span id=\"std-templatefilter-first\"></span><h3><code class=\"docutils literal notranslate\">first</code><a class=\"heading-anchor\" href=\"#first\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Mengembalikan barang pertama dalam sebuah list.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">first</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah list <code class=\"docutils literal notranslate\">['a', 'b', 'c']</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">'a'</code>.</p>\n</section>\n<section id=\"floatformat\">\n<span id=\"std-templatefilter-floatformat\"></span><h3><code class=\"docutils literal notranslate\">floatformat</code><a class=\"heading-anchor\" href=\"#floatformat\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When used without an argument, rounds a floating-point number to one decimal\nplace -- but only if there's a decimal part to be displayed. For example:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p><code class=\"docutils literal notranslate\">value</code></p></th>\n<th class=\"head\"><p>Cetakan</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.23234</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.2</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">34.00000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.26000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.3</code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Jika digunakan dengan argumen integer numerik, <code class=\"docutils literal notranslate\">floatformat</code> membulatkan ke sebanyak tempat desimal. Sebagai contoh:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p><code class=\"docutils literal notranslate\">value</code></p></th>\n<th class=\"head\"><p>Cetakan</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.23234</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:3 }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.232</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">34.00000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:3 }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.000</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.26000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:3 }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.260</code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Particularly useful is passing 0 (zero) as the argument which will round the\nfloat to the nearest integer.</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p><code class=\"docutils literal notranslate\">value</code></p></th>\n<th class=\"head\"><p>Cetakan</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.23234</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;0&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">34.00000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;0&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">39.56000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;0&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">40</code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>If the argument passed to <code class=\"docutils literal notranslate\">floatformat</code> is negative, it will round a number\nto that many decimal places -- but only if there's a decimal part to be\ndisplayed. For example:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p><code class=\"docutils literal notranslate\">value</code></p></th>\n<th class=\"head\"><p>Cetakan</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.23234</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;-3&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.232</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">34.00000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;-3&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.26000</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;-3&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.260</code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>If the argument passed to <code class=\"docutils literal notranslate\">floatformat</code> has the <code class=\"docutils literal notranslate\">g</code> suffix, it will force\ngrouping by the <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-THOUSAND_SEPARATOR\"><code class=\"xref std std-setting docutils literal notranslate\">THOUSAND_SEPARATOR</code></a> for the active locale. For\nexample, when the active locale is <code class=\"docutils literal notranslate\">en</code> (English):</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p><code class=\"docutils literal notranslate\">value</code></p></th>\n<th class=\"head\"><p>Cetakan</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34232.34</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;2g&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34,232.34</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">34232.06</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;g&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34,232.1</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34232.00</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;-3g&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34,232</code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Output is always localized (independently of the <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/formatting/#std-templatetag-localize\"><code class=\"xref std std-ttag docutils literal notranslate\">{% localize off %}</code></a> tag) unless the argument passed to <code class=\"docutils literal notranslate\">floatformat</code> has the <code class=\"docutils literal notranslate\">u</code>\nsuffix, which will force disabling localization. For example, when the active\nlocale is <code class=\"docutils literal notranslate\">pl</code> (Polish):</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p><code class=\"docutils literal notranslate\">value</code></p></th>\n<th class=\"head\"><p>Cetakan</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">34.23234</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;3&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34,232</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">34.23234</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">{{ value|floatformat:&quot;3u&quot; }}</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">34.232</code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Using <code class=\"docutils literal notranslate\">floatformat</code> with no argument is equivalent to using <code class=\"docutils literal notranslate\">floatformat</code>\nwith an argument of <code class=\"docutils literal notranslate\">-1</code>.</p>\n</section>\n<section id=\"force-escape\">\n<span id=\"std-templatefilter-force_escape\"></span><h3><code class=\"docutils literal notranslate\">force_escape</code><a class=\"heading-anchor\" href=\"#force-escape\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Applies HTML escaping to a string (see the <a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> filter for\ndetails). This filter is applied <em>immediately</em> and returns a new, escaped\nstring. This is useful in the rare cases where you need multiple escaping or\nwant to apply other filters to the escaped results. Normally, you want to use\nthe <a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> filter.</p>\n<p>For example, if you want to catch the <code class=\"docutils literal notranslate\">&lt;p&gt;</code> HTML elements created by\nthe <a class=\"reference internal\" href=\"#std-templatefilter-linebreaks\"><code class=\"xref std std-tfilter docutils literal notranslate\">linebreaks</code></a> filter:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">autoescape</span> <span class=\"nv\">off</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{{</span> <span class=\"nv\">body</span><span class=\"o\">|</span><span class=\"nf\">linebreaks</span><span class=\"o\">|</span><span class=\"nf\">force_escape</span> <span class=\"cp\">}}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">endautoescape</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"get-digit\">\n<span id=\"std-templatefilter-get_digit\"></span><h3><code class=\"docutils literal notranslate\">get_digit</code><a class=\"heading-anchor\" href=\"#get-digit\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Given a whole number, returns the requested digit, where 1 is the right-most\ndigit, 2 is the second-right-most digit, etc. Returns the original value for\ninvalid input (if input or argument is not an integer, or if argument is less\nthan 1). Otherwise, output is always an integer.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">get_digit</span><span class=\"s2\">:&quot;2&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">123456789</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">8</code>.</p>\n</section>\n<section id=\"iriencode\">\n<span id=\"std-templatefilter-iriencode\"></span><h3><code class=\"docutils literal notranslate\">iriencode</code><a class=\"heading-anchor\" href=\"#iriencode\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Converts an IRI (Internationalized Resource Identifier) to a string that is\nsuitable for including in a URL. This is necessary if you're trying to use\nstrings containing non-ASCII characters in a URL.</p>\n<p>Itu adalah aman menggunakan penyaring ini pada string yang sudah hilang melalui penyaring <a class=\"reference internal\" href=\"#std-templatefilter-urlencode\"><code class=\"xref std std-tfilter docutils literal notranslate\">urlencode</code></a>.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">iriencode</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">value</code> is <code class=\"docutils literal notranslate\">&quot;?test=I ♥ Django&quot;</code>, the output will be\n<code class=\"docutils literal notranslate\">&quot;?test=I%20%E2%99%A5%20Django&quot;</code>.</p>\n</section>\n<section id=\"join\">\n<span id=\"std-templatefilter-join\"></span><h3><code class=\"docutils literal notranslate\">join</code><a class=\"heading-anchor\" href=\"#join\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Menggabungkan list dengan string, seperti <code class=\"docutils literal notranslate\">str.join(list)</code> Python</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">join</span><span class=\"s2\">:&quot; // &quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah daftar <code class=\"docutils literal notranslate\">['a', 'b', 'c']</code>, keluaran akan menjadi deretan karakter <code class=\"docutils literal notranslate\">&quot;a // b // c&quot;</code>.</p>\n</section>\n<section id=\"json-script\">\n<span id=\"std-templatefilter-json_script\"></span><h3><code class=\"docutils literal notranslate\">json_script</code><a class=\"heading-anchor\" href=\"#json-script\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Dengan aman mengeluarkan sebuah obyek Python sebagai JSON, dibungkus dalam sebuah etiket <code class=\"docutils literal notranslate\">&lt;script&gt;</code>, siap digunakan dengan JavaScript.</p>\n<p><strong>Argument:</strong> The optional HTML &quot;id&quot; of the <code class=\"docutils literal notranslate\">&lt;script&gt;</code> tag.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">json_script</span><span class=\"s2\">:&quot;hello-data&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah dictionary <code class=\"docutils literal notranslate\">{'hello': 'world'}</code>, keluaran akan berupa:</p>\n<div class=\"code-block\" data-language=\"html\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Html</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Html code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">script</span> <span class=\"na\">id</span><span class=\"o\">=</span><span class=\"s\">&quot;hello-data&quot;</span> <span class=\"na\">type</span><span class=\"o\">=</span><span class=\"s\">&quot;application/json&quot;</span><span class=\"p\">&gt;{</span><span class=\"s2\">&quot;hello&quot;</span><span class=\"o\">:</span> <span class=\"s2\">&quot;world&quot;</span><span class=\"p\">}&lt;/</span><span class=\"nt\">script</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>Data hasil dapat diakses dalam JavaScript seperti ini:</p>\n<div class=\"code-block\" data-language=\"javascript\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">JavaScript</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"JavaScript code\"><code><span class=\"kd\">const</span> <span class=\"nx\">value</span> <span class=\"o\">=</span> <span class=\"nb\">JSON</span><span class=\"p\">.</span><span class=\"nx\">parse</span><span class=\"p\">(</span><span class=\"nb\">document</span><span class=\"p\">.</span><span class=\"nx\">getElementById</span><span class=\"p\">(</span><span class=\"s1\">&#39;hello-data&#39;</span><span class=\"p\">).</span><span class=\"nx\">textContent</span><span class=\"p\">);</span>\n</code></pre></div>\n<p>Serangan XSS dikurangi dengan meloloskan karakter &quot;&lt;&quot;, &quot;&gt;&quot; dan &quot;&amp;&quot;. Sebagai contoh jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">{'hello': 'world&lt;/script&gt;&amp;amp;'}</code>, keluaran adalah:</p>\n<div class=\"code-block\" data-language=\"html\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Html</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Html code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">script</span> <span class=\"na\">id</span><span class=\"o\">=</span><span class=\"s\">&quot;hello-data&quot;</span> <span class=\"na\">type</span><span class=\"o\">=</span><span class=\"s\">&quot;application/json&quot;</span><span class=\"p\">&gt;{</span><span class=\"s2\">&quot;hello&quot;</span><span class=\"o\">:</span> <span class=\"s2\">&quot;world\\\\u003C/script\\\\u003E\\\\u0026amp;&quot;</span><span class=\"p\">}&lt;/</span><span class=\"nt\">script</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>This is compatible with a strict Content Security Policy that prohibits in-page\nscript execution. It also maintains a clean separation between passive data and\nexecutable code.</p>\n</section>\n<section id=\"last\">\n<span id=\"std-templatefilter-last\"></span><h3><code class=\"docutils literal notranslate\">last</code><a class=\"heading-anchor\" href=\"#last\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Mengembalikan barang terakhir di daftar.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">last</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah daftar <code class=\"docutils literal notranslate\">['a', 'b', 'c', 'd']</code>, keluaran akan menjadi deretan karakter <code class=\"docutils literal notranslate\">&quot;d&quot;</code>.</p>\n</section>\n<section id=\"length\">\n<span id=\"std-templatefilter-length\"></span><h3><code class=\"docutils literal notranslate\">length</code><a class=\"heading-anchor\" href=\"#length\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Mengembalikan panjang nilai. Ini bekerja pada kedua deretan karakter dan daftar.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">length</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">['a', 'b', 'c', 'd']</code> atau <code class=\"docutils literal notranslate\">&quot;abcd&quot;</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">4</code>.</p>\n<p>Penyaring mengembalikan <code class=\"docutils literal notranslate\">0</code> untuk variabel tidak ditentukan.</p>\n</section>\n<section id=\"length-is\">\n<span id=\"std-templatefilter-length_is\"></span><h3><code class=\"docutils literal notranslate\">length_is</code><a class=\"heading-anchor\" href=\"#length-is\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<aside class=\"version-note version-deprecated\" data-version=\"4.2\" role=\"note\">\n<p class=\"version-note-title\">Deprecated since Django 4.2</p><p><span class=\"versionmodified deprecated\">Ditinggalkan sejak versi 4.2.</span></p>\n</aside>\n<p>Mengembalikan <code class=\"docutils literal notranslate\">True</code> jika panjang nilai adalah argumen, atau <code class=\"docutils literal notranslate\">False</code> sebaliknya.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">length_is</span><span class=\"s2\">:&quot;4&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">['a', 'b', 'c', 'd']</code> atau <code class=\"docutils literal notranslate\">&quot;abcd&quot;</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">True</code>.</p>\n</section>\n<section id=\"linebreaks\">\n<span id=\"std-templatefilter-linebreaks\"></span><h3><code class=\"docutils literal notranslate\">linebreaks</code><a class=\"heading-anchor\" href=\"#linebreaks\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Replaces line breaks in plain text with appropriate HTML; a single\nnewline becomes an HTML line break (<code class=\"docutils literal notranslate\">&lt;br&gt;</code>) and a new line\nfollowed by a blank line becomes a paragraph break (<code class=\"docutils literal notranslate\">&lt;/p&gt;</code>).</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">linebreaks</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">Joel\\nis a slug</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&lt;p&gt;Joel&lt;br&gt;is a slug&lt;/p&gt;</code>.</p>\n</section>\n<section id=\"linebreaksbr\">\n<span id=\"std-templatefilter-linebreaksbr\"></span><h3><code class=\"docutils literal notranslate\">linebreaksbr</code><a class=\"heading-anchor\" href=\"#linebreaksbr\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Merubah semua baris baru dalam potongan teks polos menjadi jeda baris HTML (<code class=\"docutils literal notranslate\">&lt;br&gt;</code>).</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">linebreaksbr</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">Joel\\nis a slug</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">Joel&lt;br&gt;is a slug</code>.</p>\n</section>\n<section id=\"linenumbers\">\n<span id=\"std-templatefilter-linenumbers\"></span><h3><code class=\"docutils literal notranslate\">linenumbers</code><a class=\"heading-anchor\" href=\"#linenumbers\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Menampilkan teks dengan baris angka.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">linenumbers</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>one\ntwo\nthree\n</code></pre></div>\n<p>the output will be:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>1. one\n2. two\n3. three\n</code></pre></div>\n</section>\n<section id=\"ljust\">\n<span id=\"std-templatefilter-ljust\"></span><h3><code class=\"docutils literal notranslate\">ljust</code><a class=\"heading-anchor\" href=\"#ljust\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Rata-kiri nilai dalam sebuah bidang dari lebar yang diberikan.</p>\n<p><strong>Argumen:</strong> ukuran bidang</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>&quot;<span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">ljust</span><span class=\"s2\">:&quot;10&quot;</span> <span class=\"cp\">}}</span>&quot;\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">Django</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;Django&#160;&#160;&#160; &quot;</code>.</p>\n</section>\n<section id=\"lower\">\n<span id=\"std-templatefilter-lower\"></span><h3><code class=\"docutils literal notranslate\">lower</code><a class=\"heading-anchor\" href=\"#lower\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Merubah string menjadi huruf kecil semua.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">lower</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">Totally LOVING this Album!</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">totally loving this album!</code>.</p>\n</section>\n<section id=\"make-list\">\n<span id=\"std-templatefilter-make_list\"></span><h3><code class=\"docutils literal notranslate\">make_list</code><a class=\"heading-anchor\" href=\"#make-list\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Returns the value turned into a list. For a string, it's a list of characters.\nFor an integer, the argument is cast to a string before creating a list.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">make_list</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah string <code class=\"docutils literal notranslate\">&quot;Joel&quot;</code>, keluara akan berupa list <code class=\"docutils literal notranslate\">['J', 'o', 'e', 'l']</code>. Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">123</code>, keluaran akan berupa list <code class=\"docutils literal notranslate\">['1', '2', '3']</code>.</p>\n</section>\n<section id=\"phone2numeric\">\n<span id=\"std-templatefilter-phone2numeric\"></span><h3><code class=\"docutils literal notranslate\">phone2numeric</code><a class=\"heading-anchor\" href=\"#phone2numeric\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Merubah nomor telepon (kemunginan mengandung huruf) ke setara numeriknya.</p>\n<p>Masukan tidak harus berupa nomor telepon sah. Ini akan membuat bahagia merubah string apapun.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">phone2numeric</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">800-COLLECT</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">800-2655328</code>.</p>\n</section>\n<section id=\"pluralize\">\n<span id=\"std-templatefilter-pluralize\"></span><h3><code class=\"docutils literal notranslate\">pluralize</code><a class=\"heading-anchor\" href=\"#pluralize\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Returns a plural suffix if the value is not <code class=\"docutils literal notranslate\">1</code>, <code class=\"docutils literal notranslate\">'1'</code>, or an object of\nlength 1. By default, this suffix is <code class=\"docutils literal notranslate\">'s'</code>.</p>\n<p>Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>You have <span class=\"cp\">{{</span> <span class=\"nv\">num_messages</span> <span class=\"cp\">}}</span> message<span class=\"cp\">{{</span> <span class=\"nv\">num_messages</span><span class=\"o\">|</span><span class=\"nf\">pluralize</span> <span class=\"cp\">}}</span>.\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">num_messages</code> adalah <code class=\"docutils literal notranslate\">1</code>, keluaran kan berupa <code class=\"docutils literal notranslate\">You have 1 message.</code> Jika <code class=\"docutils literal notranslate\">num_messages</code> adalah <code class=\"docutils literal notranslate\">2</code>  keluaran akan berupa <code class=\"docutils literal notranslate\">You have 2 messages.</code></p>\n<p>For words that require a suffix other than <code class=\"docutils literal notranslate\">'s'</code>, you can provide an alternate\nsuffix as a parameter to the filter.</p>\n<p>Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>You have <span class=\"cp\">{{</span> <span class=\"nv\">num_walruses</span> <span class=\"cp\">}}</span> walrus<span class=\"cp\">{{</span> <span class=\"nv\">num_walruses</span><span class=\"o\">|</span><span class=\"nf\">pluralize</span><span class=\"s2\">:&quot;es&quot;</span> <span class=\"cp\">}}</span>.\n</code></pre></div>\n<p>For words that don't pluralize by simple suffix, you can specify both a\nsingular and plural suffix, separated by a comma.</p>\n<p>Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>You have <span class=\"cp\">{{</span> <span class=\"nv\">num_cherries</span> <span class=\"cp\">}}</span> cherr<span class=\"cp\">{{</span> <span class=\"nv\">num_cherries</span><span class=\"o\">|</span><span class=\"nf\">pluralize</span><span class=\"s2\">:&quot;y,ies&quot;</span> <span class=\"cp\">}}</span>.\n</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>Use <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/translation/#std-templatetag-blocktranslate\"><code class=\"xref std std-ttag docutils literal notranslate\">blocktranslate</code></a> to pluralize translated strings.</p>\n</aside>\n</section>\n<section id=\"pprint\">\n<span id=\"std-templatefilter-pprint\"></span><h3><code class=\"docutils literal notranslate\">pprint</code><a class=\"heading-anchor\" href=\"#pprint\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Sebuah pembungkus disekitar <a class=\"reference external\" href=\"https://docs.python.org/3/library/pprint.html#pprint.pprint\" title=\"(di Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">pprint.pprint()</code></a> -- untuk mencari kesalahan, sungguh.</p>\n</section>\n<section id=\"random\">\n<span id=\"std-templatefilter-random\"></span><h3><code class=\"docutils literal notranslate\">random</code><a class=\"heading-anchor\" href=\"#random\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Mengembalikan barang acak dari list yang diberikan.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">random</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah list <code class=\"docutils literal notranslate\">['a', 'b', 'c', 'd']</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;b&quot;</code>.</p>\n</section>\n<section id=\"rjust\">\n<span id=\"std-templatefilter-rjust\"></span><h3><code class=\"docutils literal notranslate\">rjust</code><a class=\"heading-anchor\" href=\"#rjust\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Right-aligns the value in a field of a given width.</p>\n<p><strong>Argumen:</strong> ukuran bidang</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>&quot;<span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">rjust</span><span class=\"s2\">:&quot;10&quot;</span> <span class=\"cp\">}}</span>&quot;\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">Django</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">&quot; Django&quot;</code>.</p>\n</section>\n<section id=\"safe\">\n<span id=\"std-templatefilter-safe\"></span><h3><code class=\"docutils literal notranslate\">safe</code><a class=\"heading-anchor\" href=\"#safe\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Marks a string as not requiring further HTML escaping prior to output. When\nautoescaping is off, this filter has no effect.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>If you are chaining filters, a filter applied after <code class=\"docutils literal notranslate\">safe</code> can\nmake the contents unsafe again. For example, the following code\nprints the variable as is, unescaped:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">var</span><span class=\"o\">|</span><span class=\"nf\">safe</span><span class=\"o\">|</span><span class=\"nf\">escape</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n</aside>\n</section>\n<section id=\"safeseq\">\n<span id=\"std-templatefilter-safeseq\"></span><h3><code class=\"docutils literal notranslate\">safeseq</code><a class=\"heading-anchor\" href=\"#safeseq\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Applies the <a class=\"reference internal\" href=\"#std-templatefilter-safe\"><code class=\"xref std std-tfilter docutils literal notranslate\">safe</code></a> filter to each element of a sequence. Useful in\nconjunction with other filters that operate on sequences, such as\n<a class=\"reference internal\" href=\"#std-templatefilter-join\"><code class=\"xref std std-tfilter docutils literal notranslate\">join</code></a>. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">some_list</span><span class=\"o\">|</span><span class=\"nf\">safeseq</span><span class=\"o\">|</span><span class=\"nf\">join</span><span class=\"s2\">:&quot;, &quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>You couldn't use the <a class=\"reference internal\" href=\"#std-templatefilter-safe\"><code class=\"xref std std-tfilter docutils literal notranslate\">safe</code></a> filter directly in this case, as it would\nfirst convert the variable into a string, rather than working with the\nindividual elements of the sequence.</p>\n</section>\n<section id=\"slice\">\n<span id=\"std-templatefilter-slice\"></span><h3><code class=\"docutils literal notranslate\">slice</code><a class=\"heading-anchor\" href=\"#slice\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Mengembalikan potongan dari list.</p>\n<p>Uses the same syntax as Python's list slicing. See the <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/introduction.html#lists\">Python documentation</a> for an\nintroduction.</p>\n<p>Example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">some_list</span><span class=\"o\">|</span><span class=\"nf\">slice</span><span class=\"s2\">:&quot;:2&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">some_list</code> is <code class=\"docutils literal notranslate\">['a', 'b', 'c']</code>, keluaran akn berupa <code class=\"docutils literal notranslate\">['a', 'b']</code>.</p>\n</section>\n<section id=\"slugify\">\n<span id=\"std-templatefilter-slugify\"></span><h3><code class=\"docutils literal notranslate\">slugify</code><a class=\"heading-anchor\" href=\"#slugify\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Merubah ke ASCII. Merubah ruang menjadi tanda garis. Memindahkan karakter yang tidak alphanumerik, garis bawah, atau tanda garis. Merubah ke huruf kecil. Juga melucuti terkemuka dan buntutan ruang kosong.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">slugify</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;Joel is a slug&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;joel-is-a-slug&quot;</code>.</p>\n</section>\n<section id=\"stringformat\">\n<span id=\"std-templatefilter-stringformat\"></span><h3><code class=\"docutils literal notranslate\">stringformat</code><a class=\"heading-anchor\" href=\"#stringformat\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Formats the variable according to the argument, a string formatting specifier.\nThis specifier uses the <a class=\"reference external\" href=\"https://docs.python.org/3/library/stdtypes.html#old-string-formatting\" title=\"(di Python v3.14)\"><span>printf-style String Formatting</span></a> syntax, with the exception\nthat the leading &quot;%&quot; is dropped.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">stringformat</span><span class=\"s2\">:&quot;E&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">10</code>, keluaran kana berupa <code class=\"docutils literal notranslate\">1.000000E+01</code>.</p>\n</section>\n<section id=\"striptags\">\n<span id=\"std-templatefilter-striptags\"></span><h3><code class=\"docutils literal notranslate\">striptags</code><a class=\"heading-anchor\" href=\"#striptags\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Membuat semua kemungkinan usaha untuk menghapus semua etiket [X]HTML.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">striptags</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;&lt;b&gt;Joel&lt;/b&gt; &lt;button&gt;is&lt;/button&gt; a &lt;span&gt;slug&lt;/span&gt;&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;Joel is a slug&quot;</code>.</p>\n<aside class=\"admonition-no-safety-guarantee admonition\" role=\"note\">\n<p class=\"admonition-title\">Tidak ada jaminan keamanan</p>\n<p>Note that <code class=\"docutils literal notranslate\">striptags</code> doesn't give any guarantee about its output being\nHTML safe, particularly with non valid HTML input. So <strong>NEVER</strong> apply the\n<code class=\"docutils literal notranslate\">safe</code> filter to a <code class=\"docutils literal notranslate\">striptags</code> output. If you are looking for something\nmore robust, consider using a third-party HTML sanitizing tool.</p>\n</aside>\n</section>\n<section id=\"time\">\n<span id=\"std-templatefilter-time\"></span><h3><code class=\"docutils literal notranslate\">time</code><a class=\"heading-anchor\" href=\"#time\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Bentuk waktu menurut pada bentuk yang diberikan.</p>\n<p>Given format can be the predefined one <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-TIME_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">TIME_FORMAT</code></a>, or a custom\nformat, same as the <a class=\"reference internal\" href=\"#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> filter. Note that the predefined format\nis locale-dependent.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">time</span><span class=\"s2\">:&quot;H:i&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> setara pada <code class=\"docutils literal notranslate\">datetime.datetime.now()</code>, keluaran akan berupa string <code class=\"docutils literal notranslate\">&quot;01:23&quot;</code>.</p>\n<p>Note that you can backslash-escape a format string if you want to use the\n&quot;raw&quot; value. In this example, both &quot;h&quot; and &quot;m&quot; are backslash-escaped, because\notherwise each is a format string that displays the hour and the month,\nrespectively:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">time</span><span class=\"s2\">:&quot;H\\h i\\m&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>This would display as &quot;01h 23m&quot;.</p>\n<p>Contoh lain:</p>\n<p>Assuming that <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-LANGUAGE_CODE\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGE_CODE</code></a> is, for example, <code class=\"docutils literal notranslate\">&quot;de&quot;</code>, then for:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">time</span><span class=\"s2\">:&quot;TIME_FORMAT&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>the output will be the string <code class=\"docutils literal notranslate\">&quot;01:23&quot;</code> (The <code class=\"docutils literal notranslate\">&quot;TIME_FORMAT&quot;</code> format\nspecifier for the <code class=\"docutils literal notranslate\">de</code> locale as shipped with Django is <code class=\"docutils literal notranslate\">&quot;H:i&quot;</code>).</p>\n<p>The <code class=\"docutils literal notranslate\">time</code> filter will only accept parameters in the format string that\nrelate to the time of day, not the date. If you need to format a <code class=\"docutils literal notranslate\">date</code>\nvalue, use the <a class=\"reference internal\" href=\"#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> filter instead (or along with <a class=\"reference internal\" href=\"#std-templatefilter-time\"><code class=\"xref std std-tfilter docutils literal notranslate\">time</code></a> if\nyou need to render a full <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(di Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a> value).</p>\n<p>There is one exception the above rule: When passed a <code class=\"docutils literal notranslate\">datetime</code> value with\nattached timezone information (a <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/timezones/#naive-vs-aware-datetimes\"><span class=\"std std-ref\">time-zone-aware</span></a> <code class=\"docutils literal notranslate\">datetime</code> instance) the <code class=\"docutils literal notranslate\">time</code> filter will\naccept the timezone-related <a class=\"reference internal\" href=\"#date-and-time-formatting-specifiers\"><span class=\"std std-ref\">format specifiers</span></a> <code class=\"docutils literal notranslate\">'e'</code>, <code class=\"docutils literal notranslate\">'O'</code> , <code class=\"docutils literal notranslate\">'T'</code> and <code class=\"docutils literal notranslate\">'Z'</code>.</p>\n<p>When used without a format string, the <code class=\"docutils literal notranslate\">TIME_FORMAT</code> format specifier is\nused:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">time</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>is the same as:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">time</span><span class=\"s2\">:&quot;TIME_FORMAT&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n</section>\n<section id=\"timesince\">\n<span id=\"std-templatefilter-timesince\"></span><h3><code class=\"docutils literal notranslate\">timesince</code><a class=\"heading-anchor\" href=\"#timesince\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Bentuk tanggal seperti waktu sejak tanggal itu (misalnya, &quot;4 days, 6 hours&quot;).</p>\n<p>Takes an optional argument that is a variable containing the date to use as\nthe comparison point (without the argument, the comparison point is <em>now</em>).\nFor example, if <code class=\"docutils literal notranslate\">blog_date</code> is a date instance representing midnight on 1\nJune 2006, and <code class=\"docutils literal notranslate\">comment_date</code> is a date instance for 08:00 on 1 June 2006,\nthen the following would return &quot;8 hours&quot;:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">blog_date</span><span class=\"o\">|</span><span class=\"nf\">timesince</span><span class=\"o\">:</span><span class=\"nv\">comment_date</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Comparing offset-naive and offset-aware datetimes will return an empty string.</p>\n<p>Minutes is the smallest unit used, and &quot;0 minutes&quot; will be returned for any\ndate that is in the future relative to the comparison point.</p>\n</section>\n<section id=\"timeuntil\">\n<span id=\"std-templatefilter-timeuntil\"></span><h3><code class=\"docutils literal notranslate\">timeuntil</code><a class=\"heading-anchor\" href=\"#timeuntil\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Similar to <code class=\"docutils literal notranslate\">timesince</code>, except that it measures the time from now until the\ngiven date or datetime. For example, if today is 1 June 2006 and\n<code class=\"docutils literal notranslate\">conference_date</code> is a date instance holding 29 June 2006, then\n<code class=\"docutils literal notranslate\">{{ conference_date|timeuntil }}</code> will return &quot;4 weeks&quot;.</p>\n<p>Takes an optional argument that is a variable containing the date to use as\nthe comparison point (instead of <em>now</em>). If <code class=\"docutils literal notranslate\">from_date</code> contains 22 June\n2006, then the following will return &quot;1 week&quot;:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">conference_date</span><span class=\"o\">|</span><span class=\"nf\">timeuntil</span><span class=\"o\">:</span><span class=\"nv\">from_date</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Comparing offset-naive and offset-aware datetimes will return an empty string.</p>\n<p>Minutes is the smallest unit used, and &quot;0 minutes&quot; will be returned for any\ndate that is in the past relative to the comparison point.</p>\n</section>\n<section id=\"title\">\n<span id=\"std-templatefilter-title\"></span><h3><code class=\"docutils literal notranslate\">title</code><a class=\"heading-anchor\" href=\"#title\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Converts a string into titlecase by making words start with an uppercase\ncharacter and the remaining characters lowercase. This tag makes no effort to\nkeep &quot;trivial words&quot; in lowercase.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">title</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;my FIRST post&quot;</code>,keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;My First Post&quot;</code>.</p>\n</section>\n<section id=\"truncatechars\">\n<span id=\"std-templatefilter-truncatechars\"></span><h3><code class=\"docutils literal notranslate\">truncatechars</code><a class=\"heading-anchor\" href=\"#truncatechars\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Truncates a string if it is longer than the specified number of characters.\nTruncated strings will end with a translatable ellipsis character (&quot;…&quot;).</p>\n<p><strong>Argumen:</strong> Jumah karakter dipotong</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">truncatechars</span><span class=\"o\">:</span><span class=\"m\">7</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">value</code> is <code class=\"docutils literal notranslate\">&quot;Joel is a slug&quot;</code>, the output will be <code class=\"docutils literal notranslate\">&quot;Joel i…&quot;</code>.</p>\n</section>\n<section id=\"truncatechars-html\">\n<span id=\"std-templatefilter-truncatechars_html\"></span><h3><code class=\"docutils literal notranslate\">truncatechars_html</code><a class=\"heading-anchor\" href=\"#truncatechars-html\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Similar to <a class=\"reference internal\" href=\"#std-templatefilter-truncatechars\"><code class=\"xref std std-tfilter docutils literal notranslate\">truncatechars</code></a>, except that it is aware of HTML tags. Any\ntags that are opened in the string and not closed before the truncation point\nare closed immediately after the truncation.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">truncatechars_html</span><span class=\"o\">:</span><span class=\"m\">7</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">value</code> is <code class=\"docutils literal notranslate\">&quot;&lt;p&gt;Joel is a slug&lt;/p&gt;&quot;</code>, the output will be\n<code class=\"docutils literal notranslate\">&quot;&lt;p&gt;Joel i…&lt;/p&gt;&quot;</code>.</p>\n<p>Baris baru dalam isi HTML akan dipertahankan</p>\n<aside class=\"admonition-size-of-input-string admonition\" role=\"note\">\n<p class=\"admonition-title\">Size of input string</p>\n<p>Processing large, potentially malformed HTML strings can be\nresource-intensive and impact service performance. <code class=\"docutils literal notranslate\">truncatechars_html</code>\nlimits input to the first five million characters.</p>\n</aside>\n<aside class=\"version-note version-changed\" data-version=\"3.2.22\" role=\"note\">\n<p class=\"version-note-title\">Changed in Django 3.2.22</p><p>In older versions, strings over five million characters were processed.</p>\n</aside>\n</section>\n<section id=\"truncatewords\">\n<span id=\"std-templatefilter-truncatewords\"></span><h3><code class=\"docutils literal notranslate\">truncatewords</code><a class=\"heading-anchor\" href=\"#truncatewords\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Memotong sebuah string setelah sejumlah angka dari kata.</p>\n<p><strong>Argumen:</strong> Jumlah kata untuk dipotong setelahnya</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">truncatewords</span><span class=\"o\">:</span><span class=\"m\">2</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;Joel is a slug&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;Joel is …&quot;</code>.</p>\n<p>Baris baru dalam string akan dipindahkan.</p>\n</section>\n<section id=\"truncatewords-html\">\n<span id=\"std-templatefilter-truncatewords_html\"></span><h3><code class=\"docutils literal notranslate\">truncatewords_html</code><a class=\"heading-anchor\" href=\"#truncatewords-html\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Similar to <a class=\"reference internal\" href=\"#std-templatefilter-truncatewords\"><code class=\"xref std std-tfilter docutils literal notranslate\">truncatewords</code></a>, except that it is aware of HTML tags. Any\ntags that are opened in the string and not closed before the truncation point,\nare closed immediately after the truncation.</p>\n<p>This is less efficient than <a class=\"reference internal\" href=\"#std-templatefilter-truncatewords\"><code class=\"xref std std-tfilter docutils literal notranslate\">truncatewords</code></a>, so should only be used\nwhen it is being passed HTML text.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">truncatewords_html</span><span class=\"o\">:</span><span class=\"m\">2</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;&lt;p&gt;Joel is a slug&lt;/p&gt;&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;&lt;p&gt;Joel is …&lt;/p&gt;&quot;</code>.</p>\n<p>Baris baru dalam isi HTML akan dipertahankan</p>\n<aside class=\"admonition-size-of-input-string admonition\" role=\"note\">\n<p class=\"admonition-title\">Size of input string</p>\n<p>Processing large, potentially malformed HTML strings can be\nresource-intensive and impact service performance. <code class=\"docutils literal notranslate\">truncatewords_html</code>\nlimits input to the first five million characters.</p>\n</aside>\n<aside class=\"version-note version-changed\" data-version=\"3.2.22\" role=\"note\">\n<p class=\"version-note-title\">Changed in Django 3.2.22</p><p>In older versions, strings over five million characters were processed.</p>\n</aside>\n</section>\n<section id=\"unordered-list\">\n<span id=\"std-templatefilter-unordered_list\"></span><h3><code class=\"docutils literal notranslate\">unordered_list</code><a class=\"heading-anchor\" href=\"#unordered-list\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Recursively takes a self-nested list and returns an HTML unordered list --\nWITHOUT opening and closing <code class=\"docutils literal notranslate\">&lt;ul&gt;</code> tags.</p>\n<p>The list is assumed to be in the proper format. For example, if <code class=\"docutils literal notranslate\">var</code>\ncontains <code class=\"docutils literal notranslate\">['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]</code>, then\n<code class=\"docutils literal notranslate\">{{ var|unordered_list }}</code> would return:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>States\n<span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>Kansas\n        <span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n                <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>Lawrence<span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n                <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>Topeka<span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n        <span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n        <span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>Illinois<span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</section>\n<section id=\"upper\">\n<span id=\"std-templatefilter-upper\"></span><h3><code class=\"docutils literal notranslate\">upper</code><a class=\"heading-anchor\" href=\"#upper\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Merubah string kedalam semua huruf besar.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">upper</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;Joel is a slug&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;JOEL IS A SLUG&quot;</code>.</p>\n</section>\n<section id=\"urlencode\">\n<span id=\"std-templatefilter-urlencode\"></span><h3><code class=\"docutils literal notranslate\">urlencode</code><a class=\"heading-anchor\" href=\"#urlencode\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Meloloskan sebuah nilai untuk digunakan dalam sebuah URL.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">urlencode</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;https://www.example.org/foo?a=b&amp;c=d&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">&quot;https%3A//www.example.org/foo%3Fa%3Db%26c%3Dd&quot;</code>.</p>\n<p>Sebuah argumen pilihan mengandung karakter yang harus tidak diloloskan dapat disediakan.</p>\n<p>If not provided, the '/' character is assumed safe. An empty string can be\nprovided when <em>all</em> characters should be escaped. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">urlencode</span><span class=\"s2\">:&quot;&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">value</code> is <code class=\"docutils literal notranslate\">&quot;https://www.example.org/&quot;</code>, the output will be\n<code class=\"docutils literal notranslate\">&quot;https%3A%2F%2Fwww.example.org%2F&quot;</code>.</p>\n</section>\n<section id=\"urlize\">\n<span id=\"std-templatefilter-urlize\"></span><h3><code class=\"docutils literal notranslate\">urlize</code><a class=\"heading-anchor\" href=\"#urlize\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Merubah URL dan alamat surel dalam teks menjadi tautan dapat di klik.</p>\n<p>This template tag works on links prefixed with <code class=\"docutils literal notranslate\">http://</code>, <code class=\"docutils literal notranslate\">https://</code>, or\n<code class=\"docutils literal notranslate\">www.</code>. For example, <code class=\"docutils literal notranslate\">https://djangocon.eu</code> will get converted but\n<code class=\"docutils literal notranslate\">djangocon.eu</code> won't.</p>\n<p>It also supports domain-only links ending in one of the original top level\ndomains (<code class=\"docutils literal notranslate\">.com</code>, <code class=\"docutils literal notranslate\">.edu</code>, <code class=\"docutils literal notranslate\">.gov</code>, <code class=\"docutils literal notranslate\">.int</code>, <code class=\"docutils literal notranslate\">.mil</code>, <code class=\"docutils literal notranslate\">.net</code>, and\n<code class=\"docutils literal notranslate\">.org</code>). For example, <code class=\"docutils literal notranslate\">djangoproject.com</code> gets converted.</p>\n<p>Links can have trailing punctuation (periods, commas, close-parens) and leading\npunctuation (opening parens), and <code class=\"docutils literal notranslate\">urlize</code> will still do the right thing.</p>\n<p>Tautan yang dibangkitkan oleh <code class=\"docutils literal notranslate\">urlize</code> mempunyai sebuah atribut <code class=\"docutils literal notranslate\">rel=&quot;nofollow&quot;</code> ditambahkan ke mereka.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">urlize</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">value</code> is <code class=\"docutils literal notranslate\">&quot;Check out www.djangoproject.com&quot;</code>, the output will be\n<code class=\"docutils literal notranslate\">&quot;Check out &lt;a href=&quot;http://www.djangoproject.com&quot;\nrel=&quot;nofollow&quot;&gt;www.djangoproject.com&lt;/a&gt;&quot;</code>.</p>\n<p>In addition to web links, <code class=\"docutils literal notranslate\">urlize</code> also converts email addresses into\n<code class=\"docutils literal notranslate\">mailto:</code> links. If <code class=\"docutils literal notranslate\">value</code> is\n<code class=\"docutils literal notranslate\">&quot;Send questions to foo&#64;example.com&quot;</code>, the output will be\n<code class=\"docutils literal notranslate\">&quot;Send questions to &lt;a href=&quot;mailto:foo&#64;example.com&quot;&gt;foo&#64;example.com&lt;/a&gt;&quot;</code>.</p>\n<p>The <code class=\"docutils literal notranslate\">urlize</code> filter also takes an optional parameter <code class=\"docutils literal notranslate\">autoescape</code>. If\n<code class=\"docutils literal notranslate\">autoescape</code> is <code class=\"docutils literal notranslate\">True</code>, the link text and URLs will be escaped using\nDjango's built-in <a class=\"reference internal\" href=\"#std-templatefilter-escape\"><code class=\"xref std std-tfilter docutils literal notranslate\">escape</code></a> filter. The default value for\n<code class=\"docutils literal notranslate\">autoescape</code> is <code class=\"docutils literal notranslate\">True</code>.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>If <code class=\"docutils literal notranslate\">urlize</code> is applied to text that already contains HTML markup, or to\nemail addresses that contain single quotes (<code class=\"docutils literal notranslate\">'</code>), things won't work as\nexpected. Apply this filter only to plain text.</p>\n</aside>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Peringatan</p>\n<p>Using <code class=\"docutils literal notranslate\">urlize</code> or <code class=\"docutils literal notranslate\">urlizetrunc</code> can incur a performance penalty, which\ncan become severe when applied to user controlled values such as content\nstored in a <a class=\"reference internal\" href=\"/id/5.0/ref/models/fields/#django.db.models.TextField\" title=\"django.db.models.TextField\"><code class=\"xref py py-class docutils literal notranslate\">TextField</code></a>. You can use\n<a class=\"reference internal\" href=\"#std-templatefilter-truncatechars\"><code class=\"xref std std-tfilter docutils literal notranslate\">truncatechars</code></a> to add a limit to such inputs:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">truncatechars</span><span class=\"o\">:</span><span class=\"m\">500</span><span class=\"o\">|</span><span class=\"nf\">urlize</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n</aside>\n</section>\n<section id=\"urlizetrunc\">\n<span id=\"std-templatefilter-urlizetrunc\"></span><h3><code class=\"docutils literal notranslate\">urlizetrunc</code><a class=\"heading-anchor\" href=\"#urlizetrunc\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Converts URLs and email addresses into clickable links just like <a class=\"reference internal\" href=\"#urlize\">urlize</a>, but\ntruncates URLs longer than the given character limit.</p>\n<p><strong>Argument:</strong> Number of characters that link text should be truncated to,\nincluding the ellipsis that's added if truncation is necessary.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">urlizetrunc</span><span class=\"o\">:</span><span class=\"m\">15</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalaj <code class=\"docutils literal notranslate\">&quot;Check out www.djangoproject.com&quot;</code>, keluaran akan berupa <code class=\"docutils literal notranslate\">'Check out &lt;a href=&quot;http://www.djangoproject.com&quot; rel=&quot;nofollow&quot;&gt;www.djangoproj…&lt;/a&gt;'</code>.</p>\n<p>As with <a class=\"reference internal\" href=\"#urlize\">urlize</a>, this filter should only be applied to plain text.</p>\n</section>\n<section id=\"wordcount\">\n<span id=\"std-templatefilter-wordcount\"></span><h3><code class=\"docutils literal notranslate\">wordcount</code><a class=\"heading-anchor\" href=\"#wordcount\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Mengembalikan sejumlah kata.</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">wordcount</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>Jika <code class=\"docutils literal notranslate\">value</code> adalah <code class=\"docutils literal notranslate\">&quot;Joel is a slug&quot;</code>, keluaran akan menjadi <code class=\"docutils literal notranslate\">4</code>.</p>\n</section>\n<section id=\"wordwrap\">\n<span id=\"std-templatefilter-wordwrap\"></span><h3><code class=\"docutils literal notranslate\">wordwrap</code><a class=\"heading-anchor\" href=\"#wordwrap\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Membungkus kata pada panjang baris ditentukan.</p>\n<p><strong>Argumen:</strong> jumlah dari karakter dimana membungkus teks</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">wordwrap</span><span class=\"o\">:</span><span class=\"m\">5</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">value</code> is <code class=\"docutils literal notranslate\">Joel is a slug</code>, the output would be:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code>Joel\nis a\nslug\n</code></pre></div>\n</section>\n<section id=\"yesno\">\n<span id=\"std-templatefilter-yesno\"></span><h3><code class=\"docutils literal notranslate\">yesno</code><a class=\"heading-anchor\" href=\"#yesno\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Maps values for <code class=\"docutils literal notranslate\">True</code>, <code class=\"docutils literal notranslate\">False</code>, and (optionally) <code class=\"docutils literal notranslate\">None</code>, to the strings\n&quot;yes&quot;, &quot;no&quot;, &quot;maybe&quot;, or a custom mapping passed as a comma-separated list, and\nreturns one of those strings according to the value:</p>\n<p>Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">value</span><span class=\"o\">|</span><span class=\"nf\">yesno</span><span class=\"s2\">:&quot;yeah,no,maybe&quot;</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Nilai</p></th>\n<th class=\"head\"><p>Argument</p></th>\n<th class=\"head\"><p>Keluaran</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">True</code></p></td>\n<td></td>\n<td><p><code class=\"docutils literal notranslate\">yes</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">True</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">&quot;yeah,no,maybe&quot;</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">yeah</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">False</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">&quot;yeah,no,maybe&quot;</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">no</code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">None</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">&quot;yeah,no,maybe&quot;</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">maybe</code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">None</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">&quot;yeah,no&quot;</code></p></td>\n<td><p><code class=\"docutils literal notranslate\">no</code> (merubah <code class=\"docutils literal notranslate\">None</code> menjadi <code class=\"docutils literal notranslate\">False</code> jika tidak ada pemetaan untuk <code class=\"docutils literal notranslate\">None</code> diberikan)</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n</section>\n</section>\n<section id=\"internationalization-tags-and-filters\">\n<h2>Internationalization tags and filters<a class=\"heading-anchor\" href=\"#internationalization-tags-and-filters\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django provides template tags and filters to control each aspect of\n<a class=\"reference internal\" href=\"/id/5.0/topics/i18n/\"><span class=\"doc\">internationalization</span></a> in templates. They allow for\ngranular control of translations, formatting, and time zone conversions.</p>\n<section id=\"i18n\">\n<h3><code class=\"docutils literal notranslate\">i18n</code><a class=\"heading-anchor\" href=\"#i18n\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This library allows specifying translatable text in templates.\nTo enable it, set <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-USE_I18N\"><code class=\"xref std std-setting docutils literal notranslate\">USE_I18N</code></a> to <code class=\"docutils literal notranslate\">True</code>, then load it with\n<code class=\"docutils literal notranslate\">{% load i18n %}</code>.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/translation/#specifying-translation-strings-in-template-code\"><span class=\"std std-ref\">Internasionalisasi: dalam kode cetakan</span></a>.</p>\n</section>\n<section id=\"l10n\">\n<h3><code class=\"docutils literal notranslate\">l10n</code><a class=\"heading-anchor\" href=\"#l10n\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This library provides control over the localization of values in templates.\nYou only need to load the library using <code class=\"docutils literal notranslate\">{% load l10n %}</code>.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/formatting/#topic-l10n-templates\"><span class=\"std std-ref\">Mengendalikan lokalisasi dalam cetakan-cetakan</span></a>.</p>\n</section>\n<section id=\"tz\">\n<h3><code class=\"docutils literal notranslate\">tz</code><a class=\"heading-anchor\" href=\"#tz\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This library provides control over time zone conversions in templates.\nLike <code class=\"docutils literal notranslate\">l10n</code>, you only need to load the library using <code class=\"docutils literal notranslate\">{% load tz %}</code>,\nbut you'll usually also set <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> to <code class=\"docutils literal notranslate\">True</code> so that conversion\nto local time happens by default.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/5.0/topics/i18n/timezones/#time-zones-in-templates\"><span class=\"std std-ref\">Zona waktu menyadari keluaran dalam cetakan</span></a>.</p>\n</section>\n</section>\n<section id=\"other-tags-and-filters-libraries\">\n<h2>Other tags and filters libraries<a class=\"heading-anchor\" href=\"#other-tags-and-filters-libraries\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django comes with a couple of other template-tag libraries that you have to\nenable explicitly in your <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting and enable in your\ntemplate with the <a class=\"reference internal\" href=\"#std-templatetag-load\"><code class=\"xref std std-ttag docutils literal notranslate\">{% load %}</code></a> tag.</p>\n<section id=\"django-contrib-humanize\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.humanize</code><a class=\"heading-anchor\" href=\"#django-contrib-humanize\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>A set of Django template filters useful for adding a &quot;human touch&quot; to data. See\n<a class=\"reference internal\" href=\"/id/5.0/ref/contrib/humanize/\"><span class=\"doc\">django.contrib.humanize</span></a>.</p>\n</section>\n<section id=\"static\">\n<h3><code class=\"docutils literal notranslate\">static</code><a class=\"heading-anchor\" href=\"#static\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"std-templatetag-static\">\n<span id=\"id7\"></span><h4><code class=\"docutils literal notranslate\">static</code><a class=\"heading-anchor\" href=\"#std-templatetag-static\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>To link to static files that are saved in <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_ROOT</code></a> Django ships\nwith a <a class=\"reference internal\" href=\"#std-templatetag-static\"><code class=\"xref std std-ttag docutils literal notranslate\">static</code></a> template tag. If the <a class=\"reference internal\" href=\"/id/5.0/ref/contrib/staticfiles/#module-django.contrib.staticfiles\" title=\"django.contrib.staticfiles: An app for handling static files.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.staticfiles</code></a>\napp is installed, the tag will serve files using <code class=\"docutils literal notranslate\">url()</code> method of the\nstorage specified by <code class=\"docutils literal notranslate\">staticfiles</code> in <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-STORAGES\"><code class=\"xref std std-setting docutils literal notranslate\">STORAGES</code></a>. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">static</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">img</span> <span class=\"na\">src</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">static</span> <span class=\"s1\">&#39;images/hi.jpg&#39;</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span> <span class=\"na\">alt</span><span class=\"o\">=</span><span class=\"s\">&quot;Hi!&quot;</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>It is also able to consume standard context variables, e.g. assuming a\n<code class=\"docutils literal notranslate\">user_stylesheet</code> variable is passed to the template:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">static</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">link</span> <span class=\"na\">rel</span><span class=\"o\">=</span><span class=\"s\">&quot;stylesheet&quot;</span> <span class=\"na\">href</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">static</span> <span class=\"nv\">user_stylesheet</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span> <span class=\"na\">media</span><span class=\"o\">=</span><span class=\"s\">&quot;screen&quot;</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>If you'd like to retrieve a static URL without displaying it, you can use a\nslightly different call:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">static</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">static</span> <span class=\"s2\">&quot;images/hi.jpg&quot;</span> <span class=\"k\">as</span> <span class=\"nv\">myphoto</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">img</span> <span class=\"na\">src</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">myphoto</span> <span class=\"cp\">}}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<aside class=\"admonition-using-jinja2-templates admonition\" role=\"note\">\n<p class=\"admonition-title\">Menggunakan cetakan Jinja2?</p>\n<p>See <a class=\"reference internal\" href=\"/id/5.0/topics/templates/#django.template.backends.jinja2.Jinja2\" title=\"django.template.backends.jinja2.Jinja2\"><code class=\"xref py py-class docutils literal notranslate\">Jinja2</code></a> for information on\nusing the <code class=\"docutils literal notranslate\">static</code> tag with Jinja2.</p>\n</aside>\n</section>\n<section id=\"get-static-prefix\">\n<span id=\"std-templatetag-get_static_prefix\"></span><h4><code class=\"docutils literal notranslate\">get_static_prefix</code><a class=\"heading-anchor\" href=\"#get-static-prefix\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>You should prefer the <a class=\"reference internal\" href=\"#std-templatetag-static\"><code class=\"xref std std-ttag docutils literal notranslate\">static</code></a> template tag, but if you need more control\nover exactly where and how <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a> is injected into the template,\nyou can use the <a class=\"reference internal\" href=\"#std-templatetag-get_static_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\">get_static_prefix</code></a> template tag:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">static</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">img</span> <span class=\"na\">src</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">get_static_prefix</span> <span class=\"cp\">%}</span><span class=\"s\">images/hi.jpg&quot;</span> <span class=\"na\">alt</span><span class=\"o\">=</span><span class=\"s\">&quot;Hi!&quot;</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>There's also a second form you can use to avoid extra processing if you need\nthe value multiple times:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">static</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{%</span> <span class=\"k\">get_static_prefix</span> <span class=\"k\">as</span> <span class=\"nv\">STATIC_PREFIX</span> <span class=\"cp\">%}</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">img</span> <span class=\"na\">src</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">STATIC_PREFIX</span> <span class=\"cp\">}}</span><span class=\"s\">images/hi.jpg&quot;</span> <span class=\"na\">alt</span><span class=\"o\">=</span><span class=\"s\">&quot;Hi!&quot;</span><span class=\"p\">&gt;</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">img</span> <span class=\"na\">src</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{{</span> <span class=\"nv\">STATIC_PREFIX</span> <span class=\"cp\">}}</span><span class=\"s\">images/hi2.jpg&quot;</span> <span class=\"na\">alt</span><span class=\"o\">=</span><span class=\"s\">&quot;Hello!&quot;</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</section>\n<section id=\"get-media-prefix\">\n<span id=\"std-templatetag-get_media_prefix\"></span><h4><code class=\"docutils literal notranslate\">get_media_prefix</code><a class=\"heading-anchor\" href=\"#get-media-prefix\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Similar to the <a class=\"reference internal\" href=\"#std-templatetag-get_static_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\">get_static_prefix</code></a>, <code class=\"docutils literal notranslate\">get_media_prefix</code> populates a\ntemplate variable with the media prefix <a class=\"reference internal\" href=\"/id/5.0/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_URL</code></a>, e.g.:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">static</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">body</span> <span class=\"na\">data-media-url</span><span class=\"o\">=</span><span class=\"s\">&quot;</span><span class=\"cp\">{%</span> <span class=\"k\">get_media_prefix</span> <span class=\"cp\">%}</span><span class=\"s\">&quot;</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>By storing the value in a data attribute, we ensure it's escaped appropriately\nif we want to use it in a JavaScript context.</p>\n</section>\n</section>\n</section>","rootId":"built-in-template-tags-and-filters","toc":[{"title":"Acuan etiket siap-pakai","anchor":"built-in-tag-reference","children":[{"title":"autoescape","anchor":"autoescape","children":[]},{"title":"block","anchor":"block","children":[]},{"title":"comment","anchor":"comment","children":[]},{"title":"csrf_token","anchor":"csrf-token","children":[]},{"title":"cycle","anchor":"cycle","children":[]},{"title":"debug","anchor":"debug","children":[]},{"title":"extends","anchor":"extends","children":[]},{"title":"filter","anchor":"filter","children":[]},{"title":"firstof","anchor":"firstof","children":[]},{"title":"for","anchor":"for","children":[]},{"title":"for ... empty","anchor":"for-empty","children":[]},{"title":"if","anchor":"if","children":[{"title":"Penghubung Boolean","anchor":"boolean-operators","children":[{"title":"Penghubung ==","anchor":"operator","children":[]},{"title":"Penghubung !=","anchor":"id1","children":[]},{"title":"Penghubung <","anchor":"id2","children":[]},{"title":"Penghubung >","anchor":"id3","children":[]},{"title":"Penghubung <=","anchor":"id4","children":[]},{"title":"Penghubung >=","anchor":"id5","children":[]},{"title":"Penghubung in","anchor":"in-operator","children":[]},{"title":"Penghubung not in","anchor":"not-in-operator","children":[]},{"title":"penghubung is","anchor":"is-operator","children":[]},{"title":"penghubung is not","anchor":"is-not-operator","children":[]}]},{"title":"Filter","anchor":"filters","children":[]},{"title":"Pernyataan rumit","anchor":"complex-expressions","children":[]}]},{"title":"ifchanged","anchor":"ifchanged","children":[]},{"title":"include","anchor":"include","children":[]},{"title":"load","anchor":"load","children":[]},{"title":"lorem","anchor":"lorem","children":[]},{"title":"now","anchor":"now","children":[]},{"title":"regroup","anchor":"regroup","children":[{"title":"Mengkelompokkan pada sifat lain","anchor":"grouping-on-other-properties","children":[]}]},{"title":"resetcycle","anchor":"resetcycle","children":[]},{"title":"spaceless","anchor":"spaceless","children":[]},{"title":"templatetag","anchor":"templatetag","children":[]},{"title":"url","anchor":"url","children":[]},{"title":"verbatim","anchor":"verbatim","children":[]},{"title":"widthratio","anchor":"widthratio","children":[]},{"title":"with","anchor":"with","children":[]}]},{"title":"Petunjuk penyaring siap-pakai","anchor":"built-in-filter-reference","children":[{"title":"add","anchor":"add","children":[]},{"title":"addslashes","anchor":"addslashes","children":[]},{"title":"capfirst","anchor":"capfirst","children":[]},{"title":"center","anchor":"center","children":[]},{"title":"cut","anchor":"cut","children":[]},{"title":"date","anchor":"date","children":[]},{"title":"default","anchor":"default","children":[]},{"title":"default_if_none","anchor":"default-if-none","children":[]},{"title":"dictsort","anchor":"dictsort","children":[]},{"title":"dictsortreversed","anchor":"dictsortreversed","children":[]},{"title":"divisibleby","anchor":"divisibleby","children":[]},{"title":"escape","anchor":"escape","children":[]},{"title":"escapejs","anchor":"escapejs","children":[]},{"title":"escapeseq","anchor":"escapeseq","children":[]},{"title":"filesizeformat","anchor":"filesizeformat","children":[]},{"title":"first","anchor":"first","children":[]},{"title":"floatformat","anchor":"floatformat","children":[]},{"title":"force_escape","anchor":"force-escape","children":[]},{"title":"get_digit","anchor":"get-digit","children":[]},{"title":"iriencode","anchor":"iriencode","children":[]},{"title":"join","anchor":"join","children":[]},{"title":"json_script","anchor":"json-script","children":[]},{"title":"last","anchor":"last","children":[]},{"title":"length","anchor":"length","children":[]},{"title":"length_is","anchor":"length-is","children":[]},{"title":"linebreaks","anchor":"linebreaks","children":[]},{"title":"linebreaksbr","anchor":"linebreaksbr","children":[]},{"title":"linenumbers","anchor":"linenumbers","children":[]},{"title":"ljust","anchor":"ljust","children":[]},{"title":"lower","anchor":"lower","children":[]},{"title":"make_list","anchor":"make-list","children":[]},{"title":"phone2numeric","anchor":"phone2numeric","children":[]},{"title":"pluralize","anchor":"pluralize","children":[]},{"title":"pprint","anchor":"pprint","children":[]},{"title":"random","anchor":"random","children":[]},{"title":"rjust","anchor":"rjust","children":[]},{"title":"safe","anchor":"safe","children":[]},{"title":"safeseq","anchor":"safeseq","children":[]},{"title":"slice","anchor":"slice","children":[]},{"title":"slugify","anchor":"slugify","children":[]},{"title":"stringformat","anchor":"stringformat","children":[]},{"title":"striptags","anchor":"striptags","children":[]},{"title":"time","anchor":"time","children":[]},{"title":"timesince","anchor":"timesince","children":[]},{"title":"timeuntil","anchor":"timeuntil","children":[]},{"title":"title","anchor":"title","children":[]},{"title":"truncatechars","anchor":"truncatechars","children":[]},{"title":"truncatechars_html","anchor":"truncatechars-html","children":[]},{"title":"truncatewords","anchor":"truncatewords","children":[]},{"title":"truncatewords_html","anchor":"truncatewords-html","children":[]},{"title":"unordered_list","anchor":"unordered-list","children":[]},{"title":"upper","anchor":"upper","children":[]},{"title":"urlencode","anchor":"urlencode","children":[]},{"title":"urlize","anchor":"urlize","children":[]},{"title":"urlizetrunc","anchor":"urlizetrunc","children":[]},{"title":"wordcount","anchor":"wordcount","children":[]},{"title":"wordwrap","anchor":"wordwrap","children":[]},{"title":"yesno","anchor":"yesno","children":[]}]},{"title":"Internationalization tags and filters","anchor":"internationalization-tags-and-filters","children":[{"title":"i18n","anchor":"i18n","children":[]},{"title":"l10n","anchor":"l10n","children":[]},{"title":"tz","anchor":"tz","children":[]}]},{"title":"Other tags and filters libraries","anchor":"other-tags-and-filters-libraries","children":[{"title":"django.contrib.humanize","anchor":"django-contrib-humanize","children":[]},{"title":"static","anchor":"static","children":[{"title":"static","anchor":"std-templatetag-static","children":[]},{"title":"get_static_prefix","anchor":"get-static-prefix","children":[]},{"title":"get_media_prefix","anchor":"get-media-prefix","children":[]}]}]}],"breadcrumbs":[{"docname":"ref/index","title":"Acuan API","url":"/id/5.0/ref/"},{"docname":"ref/templates/index","title":"Templat","url":"/id/5.0/ref/templates/"}],"prev":{"docname":"ref/templates/language","title":"Bahasa cetakan Django","url":"/id/5.0/ref/templates/language/"},"next":{"docname":"ref/templates/api","title":"Bahasa cetakan Django: untuk pemrogram Python","url":"/id/5.0/ref/templates/api/"},"formats":{"html":"/id/5.0/ref/templates/builtins/","markdown":"/id/5.0/ref/templates/builtins.md","json":"/id/5.0/ref/templates/builtins.json"},"source":"https://github.com/django/django/blob/stable/5.0.x/docs/ref/templates/builtins.txt","official":"https://docs.djangoproject.com/id/5.0/ref/templates/builtins/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}