https://docs.djangoproject.com/en/4.0/ref/contrib/humanize/ Django The web framework for perfectionists with deadlines. * Overview * Download * Documentation * News * Community * Code * Issues * About * Donate Documentation Search: [ ] Search * Getting Help * el * es * fr * id * it * ja * ko * pl * pt-br * zh-hans * Language: en * 1.8 * 1.10 * 1.11 * 2.0 * 2.1 * 2.2 * 3.0 * 3.1 * 3.2 * 4.1 * dev * Documentation version: 4.0 django.contrib.humanizeP A set of Django template filters useful for adding a "human touch" to data. To activate these filters, add 'django.contrib.humanize' to your INSTALLED_APPS setting. Once you've done that, use {% load humanize %} in a template, and you'll have access to the following filters. apnumberP For numbers 1-9, returns the number spelled out. Otherwise, returns the number. This follows Associated Press style. Examples: * 1 becomes one. * 2 becomes two. * 10 becomes 10. You can pass in either an integer or a string representation of an integer. intcommaP Converts an integer or float (or a string representation of either) to a string containing commas every three digits. Examples: * 4500 becomes 4,500. * 4500.2 becomes 4,500.2. * 45000 becomes 45,000. * 450000 becomes 450,000. * 4500000 becomes 4,500,000. Format localization will be respected if enabled, e.g. with the 'de' language: * 45000 becomes '45.000'. * 450000 becomes '450.000'. intwordP Converts a large integer (or a string representation of an integer) to a friendly text representation. Translates 1.0 as a singular phrase and all other numeric values as plural, this may be incorrect for some languages. Works best for numbers over 1 million. Examples: * 1000000 becomes 1.0 million. * 1200000 becomes 1.2 million. * 1200000000 becomes 1.2 billion. * -1200000000 becomes -1.2 billion. Values up to 10^100 (Googol) are supported. Format localization will be respected if enabled, e.g. with the 'de' language: * 1000000 becomes '1,0 Million'. * 1200000 becomes '1,2 Millionen'. * 1200000000 becomes '1,2 Milliarden'. * -1200000000 becomes '-1,2 Milliarden'. naturaldayP For dates that are the current day or within one day, return "today", "tomorrow" or "yesterday", as appropriate. Otherwise, format the date using the passed in format string. Argument: Date formatting string as described in the date tag. Examples (when 'today' is 17 Feb 2007): * 16 Feb 2007 becomes yesterday. * 17 Feb 2007 becomes today. * 18 Feb 2007 becomes tomorrow. * Any other day is formatted according to given argument or the DATE_FORMAT setting if no argument is given. naturaltimeP For datetime values, returns a string representing how many seconds, minutes or hours ago it was - falling back to the timesince format if the value is more than a day old. In case the datetime value is in the future the return value will automatically use an appropriate phrase. Examples (when 'now' is 17 Feb 2007 16:30:00): * 17 Feb 2007 16:30:00 becomes now. * 17 Feb 2007 16:29:31 becomes 29 seconds ago. * 17 Feb 2007 16:29:00 becomes a minute ago. * 17 Feb 2007 16:25:35 becomes 4 minutes ago. * 17 Feb 2007 15:30:29 becomes 59 minutes ago. * 17 Feb 2007 15:30:01 becomes 59 minutes ago. * 17 Feb 2007 15:30:00 becomes an hour ago. * 17 Feb 2007 13:31:29 becomes 2 hours ago. * 16 Feb 2007 13:31:29 becomes 1 day, 2 hours ago. * 16 Feb 2007 13:30:01 becomes 1 day, 2 hours ago. * 16 Feb 2007 13:30:00 becomes 1 day, 3 hours ago. * 17 Feb 2007 16:30:30 becomes 30 seconds from now. * 17 Feb 2007 16:30:29 becomes 29 seconds from now. * 17 Feb 2007 16:31:00 becomes a minute from now. * 17 Feb 2007 16:34:35 becomes 4 minutes from now. * 17 Feb 2007 17:30:29 becomes an hour from now. * 17 Feb 2007 18:31:29 becomes 2 hours from now. * 18 Feb 2007 16:31:29 becomes 1 day from now. * 26 Feb 2007 18:31:29 becomes 1 week, 2 days from now. ordinalP Converts an integer to its ordinal as a string. Examples: * 1 becomes 1st. * 2 becomes 2nd. * 3 becomes 3rd. You can pass in either an integer or a string representation of an integer. Deploying GeoDjango The messages framework Back to Top Additional Information Support Django! Support Django! * Crockett Law Group donated to the Django Software Foundation to support Django development. Donate today! Contents * django.contrib.humanize + apnumber + intcomma + intword + naturalday + naturaltime + ordinal Browse * Prev: Deploying GeoDjango * Next: The messages framework * Table of contents * General Index * Python Module Index You are here: * Django 4.0 documentation + API Reference o contrib packages # django.contrib.humanize Getting help FAQ Try the FAQ -- it's got answers to many common questions. Index, Module Index, or Table of Contents Handy when looking for specific information. django-users mailing list Search for information in the archives of the django-users mailing list, or post a question. #django IRC channel Ask a question in the #django IRC channel, or search the IRC logs to see if it's been asked before. Django Discord Server Join the Django Discord Community. Official Django Forum Join the community on the Django Forum. Ticket tracker Report bugs with Django or Django documentation in our ticket tracker. Download: Offline (Django 4.0): HTML | PDF | ePub Provided by Read the Docs. Django Links Learn More * About Django * Getting Started with Django * Team Organization * Django Software Foundation * Code of Conduct * Diversity Statement Get Involved * Join a Group * Contribute to Django * Submit a Bug * Report a Security Issue Follow Us * GitHub * Twitter * News RSS * Django Users Mailing List Support Us * Sponsor Django * Official merchandise store * Amazon Smile * Benevity Workplace Giving Program Django * Hosting by In-kind donors * Design by Threespot & andrevv (c) 2005-2022 Django Software Foundation and individual contributors. Django is a registered trademark of the Django Software Foundation.