djangosnippets.org: Latest snippets tagged with 'humanize'https://djangosnippets.org/tags/humanize/2018-06-26T01:52:47.488552-05:00Filter to shorten Natural Time
2018-06-26T01:52:47.488552-05:00abhiramrhttps://djangosnippets.org/snippets/10649/<ul>
<li>This is a filter to shorten the natural time value obtained using naturaltime function from humanize.</li>
</ul>
Freely redistributableHuman format Date representation
2012-03-20T02:49:58.560070-05:00sachingupta006https://djangosnippets.org/snippets/2719/<p>This template tag, takes the date format of the datetime object and returns the date in a human readable format.</p>
Freely redistributableConverts an integer or floating-point number or a string to a string containing the delimiter character (default comma) after every delimeter_count digits (by default 3 digits)
2012-03-14T16:02:38.243837-05:00pikhovkinhttps://djangosnippets.org/snippets/2716/<p>Converts an integer or floating-point number or a string to a string containing the delimiter character (default comma) after every delimeter_count digits (by default 3 digits)</p>
Freely redistributableHumanized and localized timesince template filter
2010-11-26T06:19:20.695704-06:00slinkhttps://djangosnippets.org/snippets/2275/<p>Humanized and localized version of built-in <em>timesince</em> template filter.</p>
<p>Based on <a href="http://www.joeyb.org/blog/2009/10/08/custom-django-template-filter-for-humanized-timesince">Joey Bratton's idea</a>.</p>
Freely redistributabletimeto template filter
2009-04-10T11:27:30.404782-05:00japerkhttps://djangosnippets.org/snippets/1426/<p>This is a more compact version of django's <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/#timeuntil">timeuntil</a> filter that only shows hours & minutes. If used like <code>{{ dt|timeto }}</code>, will produce output like "1hr 30min". If you know for sure that the server has the same timezone as the <a href="http://docs.python.org/library/datetime.html#datetime-objects">datetime</a> value, then you don't need <a href="http://labix.org/python-dateutil#head-587bd3efc48f897f55c179abc520a34330ee0a62">datetutil.tz …</a></p>
Freely redistributableFuzzyDateTimeField
2009-04-09T16:45:33.659046-05:00japerkhttps://djangosnippets.org/snippets/1422/<p>FuzzyDateTimeField is a drop in replacement for the standard <a href="http://docs.djangoproject.com/en/dev/ref/forms/fields/#datetimefield">DateTimeField</a> that uses <a href="http://labix.org/python-dateutil#head-a23e8ae0a661d77b89dfb3476f85b26f0b30349c">dateutil.parser</a> to clean the value. It has an extra keyword argument <code>fuzzy=True</code>, which allows it to be more liberal with the input formats it accepts. Set <code>fuzzy=False</code> for more strict validation.</p>
Freely redistributableFuzzy Date Diff Template Filter
2009-03-01T03:43:17.594406-06:00zainhttps://djangosnippets.org/snippets/1347/<p>Pass in a date and you get a humanized fuzzy date diff; e.g. "2 weeks ago" or "in 5 months".
</p>
<p>The date you pass in can be in the past or future (or even the present, for that matter).
</p>
<p>The result is rounded, so a date 45 days ago will …</p>
Freely redistributable(en-US) Humanized Decimal Field
2008-07-01T14:47:19.431231-05:00ActionScriptedhttps://djangosnippets.org/snippets/842/<p>Simple DecimalField class extension that automatically adds formatting and validation for comma-separated "decimals". Works wonderfully for price fields.
</p>
<p>Could be extended to strip dollar signs or to be locale-agnostic.
</p>
Freely redistributablehumanize time difference (how long ago)
2007-09-11T13:18:56.141557-05:00supsupmohttps://djangosnippets.org/snippets/412/<p>If you ever have a need to display something like:</p>
<p>"last update 5 days ago"
"user logged in 2 mins ago"</p>
<p>you can use this script to determine how long ago a timestamp is versus now().</p>
Freely redistributableHumanize lists of strings in templates
2007-06-10T22:49:16.527746-05:00ChipX86https://djangosnippets.org/snippets/276/<p>A simple template filter for taking a list and humanizing it, converting:</p>
<p><code>["foo", "bar"]</code> to <code>"foo and bar"</code></p>
<p><code>["foo", "bar", "baz"]</code> to <code>"foo, bar and baz"</code></p>
<p><code>["foo", "bar", "baz", "42"]</code> to <code>"foo, bar, baz and 42"</code></p>
Freely redistributableTimedelta template tag
2007-04-30T13:03:21.040796-05:00dballanchttps://djangosnippets.org/snippets/210/<p>This is tag similar to <em>timesince</em> and <em>timeuntil</em>, which work great until you starting giving timesince dates in the future or timeuntil dates in the past. Timedelta tag will humanize output correctly for both future and past dates using <em>now</em> as a default reference date (or a specified reference …</p>
Freely redistributable