djangosnippets.org: Latest snippets tagged with 'capitalize'https://djangosnippets.org/tags/capitalize/2009-01-27T04:45:30.385839-06:00Filter; Capitalise Sentences (capsentence)
2009-01-27T04:45:30.385839-06:00djmhttps://djangosnippets.org/snippets/1298/<p>Given a string, it first lowercases it, then uppercases the first letter of each sentence.
Helpful when dealing with awfully formatted entirely UPPERCASE XML product data feeds.</p>
Freely redistributableName Capitalize Filter
2007-04-28T13:15:42.369170-05:00hotanihttps://djangosnippets.org/snippets/206/<p>This is to be used as a template filter. See <a href="http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters">django documentation</a> for adding custom filters.</p>
<p>Example of use:</p>
<p>name = "bart simpson"
<code>{{ name|cap }}</code> will convert 'name' to "Bart Simpson"</p>
<p>It works on space-separated names, as well as the following:</p>
<ul>
<li>converts "mcfly" to "McFly";</li>
<li>converts "o'neill" to "O'Neill"; …</li></ul>
Freely redistributable