Skip to main content
django-humanize − use humanize 3rd-party lib as template filters
================================================================

Django already offers
[django.contrib.humanize](https://docs.djangoproject.com/en/1.8/ref/contrib/humanize/)
but that implementation is lacking some features, like humanization of
durations.

That lib comes to the rescue allowing you to use *template filters*
backed on [the standalone humanize lib](https://pypi.python.org/pypi/humanize).

Install
------

Add `django_humanize` to your *INSTALLED_APPS* setting.

Examples
--------

### Template

{% load humanizelib %}

It lasted {{ duration|naturaldelta }}.

### View

import datetime
from django.shortcuts import render_

def summary(request):
context = {'duration': datetime.timedelta(seconds=1000)}
return render('template.html', context)

Will render as *"lasted 16 minutes."*.

Template filters
----------------

The following template filters are available :

- naturalday
- naturaltime
- ordinal
- intword
- naturaldelta
- intcomma
- apnumber
- fractional
- naturalsize
- naturaldate

Internationalization
---------------------

Internationalization is supported and matches Django *LANGUAGE_CODE* setting. If
it does not work, maybe, your language code is not supported by the standalone
humanize lib. Think about
[contributing it](https://github.com/jmoiron/humanize/#localization).

Release files for django-humanize 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-humanize 0.1.2
File Size Uploaded
django-humanize-0.1.2.tar.gz 2.3 kB Details

Release files / django-humanize-0.1.2.tar.gz

Download URL django-humanize-0.1.2.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
32491bf0209b89a277f7bfdab7fd6d4cc7944bb037f742d62e8e447a575c0028
BLAKE2b-256 checksum
How to use checksums
b3a8955344ecd167d6c8677fba60833fb4374e7e969d42af0e14029341e6ffc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page