{"title":"django.contrib.humanize","version":"1.10","locale":"ja","docname":"ref/contrib/humanize","url":"/ja/1.10/ref/contrib/humanize/","canonical":"https://djangodocs.dev/ja/1.10/ref/contrib/humanize/","summary":"humanize は、データに「人間くささ（human touch）」を与えるための Django テンプレートフィルタセットです。 これらのフィルタを有効にするには、 INSTALLED_APPS 設定に 'django.contrib.humanize' を加えます。インストール後、テンプレート上で {% load…","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>humanize は、データに「人間くささ（human touch）」を与えるための Django テンプレートフィルタセットです。</p>\n<p>これらのフィルタを有効にするには、 <a class=\"reference internal\" href=\"/ja/1.10/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a>  設定に <code class=\"docutils literal notranslate\">'django.contrib.humanize'</code> を加えます。インストール後、テンプレート上で <code class=\"docutils literal notranslate\">{% load humanize %}</code> を呼び出せば、以下のフィルタを利用できるようになります:</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>1-9 の数字に対して、数をアルファベットで表します。それ以外の数はそのまま数字で返します。これは AP スタイルブックの書式に従っています。</p>\n<p>例:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1</code> は <code class=\"docutils literal notranslate\">one</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">2</code> は <code class=\"docutils literal notranslate\">two</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">10</code> は <code class=\"docutils literal notranslate\">10</code> になります。</p></li>\n</ul>\n<p>渡す値は整数でも、整数を文字列で表したものでもかまいません。</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>例:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">4500</code> は <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> は <code class=\"docutils literal notranslate\">45,000</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">450000</code> は <code class=\"docutils literal notranslate\">450,000</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">4500000</code> は <code class=\"docutils literal notranslate\">4,500,000</code> になります。</p></li>\n</ul>\n<p>可能であれば <a class=\"reference internal\" href=\"/ja/1.10/topics/i18n/formatting/\"><span class=\"doc\">表示形式のローカル化</span></a> が優先されます。例えば <code class=\"docutils literal notranslate\">'de'</code> （ドイツ語）では次のようになります。</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">45000</code> は <code class=\"docutils literal notranslate\">'45.000'</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">450000</code> は <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. Works best for numbers over 1 million.</p>\n<p>例:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1000000</code> は <code class=\"docutils literal notranslate\">1.0 million</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000</code> は <code class=\"docutils literal notranslate\">1.2 million</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000000</code> は  <code class=\"docutils literal notranslate\">1.2 billion</code> になります。</p></li>\n</ul>\n<p>値は 10^100 (Googol) までサポートされます。</p>\n<p>可能であれば <a class=\"reference internal\" href=\"/ja/1.10/topics/i18n/formatting/\"><span class=\"doc\">表示形式のローカル化</span></a> が優先されます。例えば <code class=\"docutils literal notranslate\">'de'</code> （ドイツ語）では次のようになります。</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1000000</code> は <code class=\"docutils literal notranslate\">'1,0 Million'</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000</code> は <code class=\"docutils literal notranslate\">'1,2 Million'</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">1200000000</code> は <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>日付が今日、明日、昨日のいずれかに該当する場合、それぞれ「今日（“today”）」、 「明日（“tomorrow”）」、「昨日（“yesterday”）」を返します。それ以外の日付の 場合は、引数に渡したフォーマット文字列を使って日付をフォーマットします。</p>\n<p><strong>引数:</strong>  <a class=\"reference internal\" href=\"/ja/1.10/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> タグと同じ記法による日付フォーマット文字列</p>\n<p>表示例 ( 今日の日付を <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">``</span></a>2007年 2月 17日``とします ) :</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">2007年 2月 16日</code> は <code class=\"docutils literal notranslate\">yesterday</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">2007年 2月 17日</code> は <code class=\"docutils literal notranslate\">today</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">2007年 2月 18日</code> は <code class=\"docutils literal notranslate\">tomorrow</code> になります。</p></li>\n<li><p>今日、昨日、明日以外の日付は与えられた引数に従ってフォーマットされます。引数がない場合は <a class=\"reference internal\" href=\"/ja/1.10/ref/settings/#std-setting-DATE_FORMAT\"><code class=\"xref std std-setting docutils literal notranslate\">DATE_FORMAT</code></a> 設定に従います。</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>datetime 値に対して、何時間（分、秒）前であったかを表わす文字列を返します。1日以上前である場合は <a class=\"reference internal\" href=\"/ja/1.10/ref/templates/builtins/#std-templatefilter-timesince\"><code class=\"xref std std-tfilter docutils literal notranslate\">timesince</code></a> フォーマットにフォールバックします。 datetime 値が未来である場合も、自動的に適切なフレーズが返り値に使用されます。</p>\n<p>表示例 ( 現在の日時を <code class=\"docutils literal notranslate\">17 Feb 2007 16:30:00</code> とします ) :</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:30:00</code> は <code class=\"docutils literal notranslate\">now</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">17 Feb 2007 16:29:31</code> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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> は <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>整数を序数形式の文字列に変換します。</p>\n<p>例:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">1</code> は <code class=\"docutils literal notranslate\">1st</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">2</code> は <code class=\"docutils literal notranslate\">2nd</code> になります。</p></li>\n<li><p><code class=\"docutils literal notranslate\">3</code> は <code class=\"docutils literal notranslate\">3rd</code> になります。</p></li>\n</ul>\n<p>渡す値は整数でも、整数を文字列で表したものでもかまいません。</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/1.10/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/ja/1.10/ref/contrib/"}],"prev":{"docname":"ref/contrib/gis/deployment","title":"Deploying GeoDjango","url":"/ja/1.10/ref/contrib/gis/deployment/"},"next":{"docname":"ref/contrib/messages","title":"メッセージフレームワーク","url":"/ja/1.10/ref/contrib/messages/"},"formats":{"html":"/ja/1.10/ref/contrib/humanize/","markdown":"/ja/1.10/ref/contrib/humanize.md","json":"/ja/1.10/ref/contrib/humanize.json"},"source":"https://github.com/django/django/blob/stable/1.10.x/docs/ref/contrib/humanize.txt","official":"https://docs.djangoproject.com/ja/1.10/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","fr","ja","id","pt-br","es","el","pl"]}