After digging into django source code, I found a way to format a number or into a proper localization format.
Here is how to do it.
>>> from django.utils import formats
>>> from decimal import Decimal
You can check out the source code of django.utils.formats, and you can also find some other functions to localize date/time format, and also to sanitize numbers which are localized.
So, remember the DRY principle, and make sure you don't reinvent the wheel by creating existing functionalities.
I'm enjoying django more and more.