Django has a nice feature to add thousands separators to integers in templates automatically, by setting NUMBER_GROUPING=True. The problem is that for some integers (for instance 'year') you do not want decimal grouping. Somehow I can't find a filter or something else that prevents Django from adding thousands separators to my integers.
Does anyone know what I should do to exclude certain integers from being processed by the NUMBER_GROUPING process, without disabling this functionality for other integers?
Wout
Controlling localization in templates When you have enabled formatting with USE_L10N , Django will try to use a locale specific format whenever it outputs a value in a template.
Django for loop counter All the variables related to the counter are listed below. forloop. counter: By using this, the iteration of the loop starts from index 1. forloop. counter0: By using this, the iteration of the loop starts from index 0.
lorem. Displays random “lorem ipsum” Latin text. This is useful for providing sample data in templates.
Definition and Usage The autoescape tag is used to specify if autoescape is on or off. If autoescape is on, which is default, HTML code in variables will be escaped.
The NUMBER_GROUPING
setting is part of django's format localization functionality. To get rid of it in a template try {{ value|unlocalize }}
. You'll also need to {% load l10n %}
beforehand. This also seems to require django 1.3.
See the docs for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With