{"title":"django.contrib.humanize","version":"6.1","locale":"ja","docname":"ref/contrib/humanize","url":"/ja/6.1/ref/contrib/humanize/","canonical":"https://djangodocs.dev/ja/6.1/ref/contrib/humanize/","summary":"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…","html":"<span id=\"django-contrib-humanize\"></span><h1><code class=\"docutils literal notranslate\">django.contrib.humanize</code><a class=\"heading-anchor\" href=\"#module-django.contrib.humanize\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>A set of Django template filters useful for adding a &quot;human touch&quot; to data.</p>\n<p>To activate these filters, add <code class=\"docutils literal notranslate\">'django.contrib.humanize'</code> to your\n<a class=\"reference internal\" href=\"/ja/6.1/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting. Once you've done that, use\n<code class=\"docutils literal notranslate\">{% load humanize %}</code> in a template, and you'll have access to the following\nfilters.</p>\n<section id=\"apnumber\">\n<span id=\"std-templatefilter-apnumber\"></span><h2><code class=\"docutils literal notranslate\">apnumber</code><a class=\"heading-anchor\" href=\"#apnumber\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>For numbers 1-9, returns the number spelled out. Otherwise, returns the\nnumber. This follows Associated Press style.</p>\n<p>Examples:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1</code> becomes <code class=\"docutils literal notranslate\">one</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">2</code> becomes <code class=\"docutils literal notranslate\">two</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">10</code> becomes <code class=\"docutils literal notranslate\">10</code>.</p></li>\n</ul>\n<p>You can pass in either an integer or a string representation of an integer.</p>\n</section>\n<section id=\"intcomma\">\n<span id=\"std-templatefilter-intcomma\"></span><h2><code class=\"docutils literal notranslate\">intcomma</code><a class=\"heading-anchor\" href=\"#intcomma\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Converts an integer or float (or a string representation of either) to a string\ncontaining commas every three digits.</p>\n<p>Examples:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">4500</code> becomes <code class=\"docutils literal notranslate\">4,500</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">4500.2</code> becomes <code class=\"docutils literal notranslate\">4,500.2</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">45000</code> becomes <code class=\"docutils literal notranslate\">45,000</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">450000</code> becomes <code class=\"docutils literal notranslate\">450,000</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">4500000</code> becomes <code class=\"docutils literal notranslate\">4,500,000</code>.</p></li>\n</ul>\n<p><a class=\"reference internal\" href=\"/ja/6.1/topics/i18n/formatting/\"><span class=\"doc\">表示形式のローカライズ</span></a> will be respected if enabled,\ne.g. with the <code class=\"docutils literal notranslate\">'de'</code> language:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">45000</code> becomes <code class=\"docutils literal notranslate\">'45.000'</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">450000</code> becomes <code class=\"docutils literal notranslate\">'450.000'</code>.</p></li>\n</ul>\n</section>\n<section id=\"intword\">\n<span id=\"std-templatefilter-intword\"></span><h2><code class=\"docutils literal notranslate\">intword</code><a class=\"heading-anchor\" href=\"#intword\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Converts a large integer (or a string representation of an integer) to a\nfriendly text representation. Translates <code class=\"docutils literal notranslate\">1.0</code> as a singular phrase and all\nother numeric values as plural, this may be incorrect for some languages. Works\nbest for numbers over 1 million.</p>\n<p>Examples:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1000000</code> becomes <code class=\"docutils literal notranslate\">1.0 million</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000</code> becomes <code class=\"docutils literal notranslate\">1.2 million</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000000</code> becomes <code class=\"docutils literal notranslate\">1.2 billion</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">-1200000000</code> becomes <code class=\"docutils literal notranslate\">-1.2 billion</code>.</p></li>\n</ul>\n<p>Values up to 10^100 (Googol) are supported.</p>\n<p><a class=\"reference internal\" href=\"/ja/6.1/topics/i18n/formatting/\"><span class=\"doc\">表示形式のローカライズ</span></a> will be respected if enabled,\ne.g. with the <code class=\"docutils literal notranslate\">'de'</code> language:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1000000</code> becomes <code class=\"docutils literal notranslate\">'1,0 Million'</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000</code> becomes <code class=\"docutils literal notranslate\">'1,2 Millionen'</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000000</code> becomes <code class=\"docutils literal notranslate\">'1,2 Milliarden'</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">-1200000000</code> becomes <code class=\"docutils literal notranslate\">'-1,2 Milliarden'</code>.</p></li>\n</ul>\n</section>\n<section id=\"naturalday\">\n<span id=\"std-templatefilter-naturalday\"></span><h2><code class=\"docutils literal notranslate\">naturalday</code><a class=\"heading-anchor\" href=\"#naturalday\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>For dates that are the current day or within one day, return &quot;today&quot;,\n&quot;tomorrow&quot; or &quot;yesterday&quot;, as appropriate. Otherwise, format the date using\nthe passed in format string.</p>\n<p><strong>Argument:</strong> Date formatting string as described in the <a class=\"reference internal\" href=\"/ja/6.1/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> tag.</p>\n<p>Examples (when 'today' is 17 Feb 2007):</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">16 Feb 2007</code> becomes <code class=\"docutils literal notranslate\">yesterday</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007</code> becomes <code class=\"docutils literal notranslate\">today</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">18 Feb 2007</code> becomes <code class=\"docutils literal notranslate\">tomorrow</code>.</p></li>\n<li><p>Any other day is formatted according to given argument or the\n<a class=\"reference internal\" href=\"/ja/6.1/ref/settings/#std-setting-DATE_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">DATE_FORMAT</code></a> setting if no argument is given.</p></li>\n</ul>\n</section>\n<section id=\"naturaltime\">\n<span id=\"std-templatefilter-naturaltime\"></span><h2><code class=\"docutils literal notranslate\">naturaltime</code><a class=\"heading-anchor\" href=\"#naturaltime\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>For datetime values, returns a string representing how many seconds,\nminutes or hours ago it was -- falling back to the <a class=\"reference internal\" href=\"/ja/6.1/ref/templates/builtins/#std-templatefilter-timesince\"><code class=\"xref std std-tfilter docutils literal notranslate\">timesince</code></a>\nformat if the value is more than a day old. In case the datetime value is in\nthe future the return value will automatically use an appropriate phrase.</p>\n<p>Examples (when 'now' is 17 Feb 2007 16:30:00):</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:30:00</code> becomes <code class=\"docutils literal notranslate\">now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:29:31</code> becomes <code class=\"docutils literal notranslate\">29 seconds ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:29:00</code> becomes <code class=\"docutils literal notranslate\">a minute ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:25:35</code> becomes <code class=\"docutils literal notranslate\">4 minutes ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 15:30:29</code> becomes <code class=\"docutils literal notranslate\">59 minutes ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 15:30:01</code> becomes <code class=\"docutils literal notranslate\">59 minutes ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 15:30:00</code> becomes <code class=\"docutils literal notranslate\">an hour ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 13:31:29</code> becomes <code class=\"docutils literal notranslate\">2 hours ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">16 Feb 2007 13:31:29</code> becomes <code class=\"docutils literal notranslate\">1 day, 2 hours ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">16 Feb 2007 13:30:01</code> becomes <code class=\"docutils literal notranslate\">1 day, 2 hours ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">16 Feb 2007 13:30:00</code> becomes <code class=\"docutils literal notranslate\">1 day, 3 hours ago</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:30:30</code> becomes <code class=\"docutils literal notranslate\">30 seconds from now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:30:29</code> becomes <code class=\"docutils literal notranslate\">29 seconds from now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:31:00</code> becomes <code class=\"docutils literal notranslate\">a minute from now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:34:35</code> becomes <code class=\"docutils literal notranslate\">4 minutes from now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 17:30:29</code> becomes <code class=\"docutils literal notranslate\">an hour from now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 18:31:29</code> becomes <code class=\"docutils literal notranslate\">2 hours from now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">18 Feb 2007 16:31:29</code> becomes <code class=\"docutils literal notranslate\">1 day from now</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">26 Feb 2007 18:31:29</code> becomes <code class=\"docutils literal notranslate\">1 week, 2 days from now</code>.</p></li>\n</ul>\n</section>\n<section id=\"ordinal\">\n<span id=\"std-templatefilter-ordinal\"></span><h2><code class=\"docutils literal notranslate\">ordinal</code><a class=\"heading-anchor\" href=\"#ordinal\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Converts an integer to its ordinal as a string.</p>\n<p>Examples:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1</code> becomes <code class=\"docutils literal notranslate\">1st</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">2</code> becomes <code class=\"docutils literal notranslate\">2nd</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">3</code> becomes <code class=\"docutils literal notranslate\">3rd</code>.</p></li>\n</ul>\n<p>You can pass in either an integer or a string representation of an integer.\nNegative integers are returned unchanged.</p>\n</section>","rootId":"module-django.contrib.humanize","toc":[{"title":"apnumber","anchor":"apnumber","children":[]},{"title":"intcomma","anchor":"intcomma","children":[]},{"title":"intword","anchor":"intword","children":[]},{"title":"naturalday","anchor":"naturalday","children":[]},{"title":"naturaltime","anchor":"naturaltime","children":[]},{"title":"ordinal","anchor":"ordinal","children":[]}],"breadcrumbs":[{"docname":"ref/index","title":"API Reference","url":"/ja/6.1/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/ja/6.1/ref/contrib/"}],"prev":{"docname":"ref/contrib/gis/deployment","title":"Deploying GeoDjango","url":"/ja/6.1/ref/contrib/gis/deployment/"},"next":{"docname":"ref/contrib/messages","title":"The messages framework","url":"/ja/6.1/ref/contrib/messages/"},"formats":{"html":"/ja/6.1/ref/contrib/humanize/","markdown":"/ja/6.1/ref/contrib/humanize.md","json":"/ja/6.1/ref/contrib/humanize.json"},"source":"https://github.com/django/django/blob/stable/6.1.x/docs/ref/contrib/humanize.txt","official":"https://docs.djangoproject.com/ja/6.1/ref/contrib/humanize/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}