I am pulling the amount from the database, which is a decimal value. I am trying to use this value as a result of JSON
json.dumps( { 'sum': amount } )
Django cannot serialize Decimal . I can convert it to a string, but I need a digital type in JSON. If I try to convert it to float , I get more than two decimal places.
What should happen if possible to get a result similar to the following?
{ 'sum': 500.50 }
python django
Justin
source share