djangosnippets.org: Latest snippets tagged with 'template filter'https://djangosnippets.org/tags/template-filter_1/2016-09-01T21:40:45.890903-05:00Custom template filter remove words at end of a string
2016-09-01T21:40:45.890903-05:00quevon24https://djangosnippets.org/snippets/10585/<p>Filter to remove words at the end of a string</p>
<p>Example:</p>
<p>Myvar: "My name is Arthur and django si awesome"</p>
<p>{{myvar|wordend:4}}</p>
<p>Output: "My name is Arthur"</p>
Freely redistributableCustom template filter remove words at beginning of a string
2016-09-01T21:35:35.866478-05:00quevon24https://djangosnippets.org/snippets/10584/<p>Filter to remove words at the beginning of a string</p>
<p>Example:</p>
<p>Myvar: "My name is Arthur and django si awesome"</p>
<p>{{myvar|wordremoveb:5}}</p>
<p>Output: "django is awesome"</p>
Freely redistributableAdd CSS class template filter
2010-11-08T16:34:51.900894-06:00lazersciencehttps://djangosnippets.org/snippets/2253/<p>Sometimes you want to add CSS classes to HTML elements that are generated by Django using their <code>__unicode__</code> representation, eg. you can output a form field with <code>{{ form.name }}</code>, but if you would like to add a certain CSS class to the outputted input or select tag you …</p>
Freely redistributable