Django version 2.2 and 3.0
Purpose: I would like to display numbers in India locale format. For e.g. 1000000 should be displayed as 10,00,000
Action
To do this, I went to settings.py
and made the following changes:
LANGUAGE_CODE = 'IN'
- date and time was displayed in Indonesian format but grouping of numbers were correct
LANGUAGE_CODE = 'en-IN'
- date and time was displayed properly but grouping of numbers were incorrect
LANGUAGE_CODE = 'hi-IN'
- date and time had Hindi language display but grouping of numbers were correct
What I want
LANGUAGE_CODE = 'en-IN'
to display date and time properly and also do number grouping
My settings.py file :
LANGUAGE_CODE = 'en-IN'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_THOUSAND_SEPARATOR = True
NUMBER_GROUPING = (3,2, 0)
USE_TZ = True
I had a look at Number Grouping which actually talked about this but I believe documentation is misleading. For starters they have put language code as en_IN which doesn't work.
Let me know if any additional information needed.
I created a folder under my app called formats.
I placed a file called formats.py where I added the following :
NUMBER_GROUPING = (3,2,0)
THOUSAND_SEPARATOR = ','
DECIMAL_SEPARATOR = '.'
DATE_INPUT_FORMATS = ['%d-%m-%Y']