PageRenderTime 202ms CodeModel.GetById 100ms app.highlight 1ms RepoModel.GetById 100ms app.codeStats 0ms

/docs/ref/contrib/humanize.txt

https://code.google.com/p/mango-py/
Plain Text | 98 lines | 64 code | 34 blank | 0 comment | 0 complexity | 476abdd0ad2d07c8c40858b20b32e5b6 MD5 | raw file
 1========================
 2django.contrib.humanize
 3========================
 4
 5.. module:: django.contrib.humanize
 6   :synopsis: A set of Django template filters useful for adding a "human
 7              touch" to data.
 8
 9A set of Django template filters useful for adding a "human touch" to data.
10
11To activate these filters, add ``'django.contrib.humanize'`` to your
12:setting:`INSTALLED_APPS` setting. Once you've done that, use
13``{% load humanize %}`` in a template, and you'll have access to the following
14filters.
15
16.. templatefilter:: apnumber
17
18apnumber
19--------
20
21For numbers 1-9, returns the number spelled out. Otherwise, returns the
22number. This follows Associated Press style.
23
24Examples:
25
26    * ``1`` becomes ``one``.
27    * ``2`` becomes ``two``.
28    * ``10`` becomes ``10``.
29
30You can pass in either an integer or a string representation of an integer.
31
32.. templatefilter:: intcomma
33
34intcomma
35--------
36
37Converts an integer to a string containing commas every three digits.
38
39Examples:
40
41    * ``4500`` becomes ``4,500``.
42    * ``45000`` becomes ``45,000``.
43    * ``450000`` becomes ``450,000``.
44    * ``4500000`` becomes ``4,500,000``.
45
46You can pass in either an integer or a string representation of an integer.
47
48.. templatefilter:: intword
49
50intword
51-------
52
53Converts a large integer to a friendly text representation. Works best for
54numbers over 1 million.
55
56Examples:
57
58    * ``1000000`` becomes ``1.0 million``.
59    * ``1200000`` becomes ``1.2 million``.
60    * ``1200000000`` becomes ``1.2 billion``.
61
62Values up to 1000000000000000 (one quadrillion) are supported.
63
64You can pass in either an integer or a string representation of an integer.
65
66.. templatefilter:: naturalday
67
68naturalday
69----------
70
71For dates that are the current day or within one day, return "today",
72"tomorrow" or "yesterday", as appropriate. Otherwise, format the date using
73the passed in format string.
74
75**Argument:** Date formatting string as described in the :tfilter:`date` tag.
76
77Examples (when 'today' is 17 Feb 2007):
78
79    * ``16 Feb 2007`` becomes ``yesterday``.
80    * ``17 Feb 2007`` becomes ``today``.
81    * ``18 Feb 2007`` becomes ``tomorrow``.
82    * Any other day is formatted according to given argument or the
83      :setting:`DATE_FORMAT` setting if no argument is given.
84
85.. templatefilter:: ordinal
86
87ordinal
88-------
89
90Converts an integer to its ordinal as a string.
91
92Examples:
93
94    * ``1`` becomes ``1st``.
95    * ``2`` becomes ``2nd``.
96    * ``3`` becomes ``3rd``.
97
98You can pass in either an integer or a string representation of an integer.