Skip to content

Commit

Permalink
Django serializes Decimals as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
derek-schaefer committed Feb 26, 2013
1 parent cd0af7d commit 7ca9df4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test_project/app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ def test_decimal(self):
t1 = Test.objects.create(json=1.24)
self.assertEqual(Decimal('1.24'), Test.objects.get(pk=t1.pk).json)
t2 = Test.objects.create(json=Decimal(1.24))
self.assertEqual(Decimal(1.24), Test.objects.get(pk=t2.pk).json)
dec_str = '1.2399999999999999911182158029987476766109466552734375'
self.assertEqual(dec_str, Test.objects.get(pk=t2.pk).json)
t3 = Test.objects.create(json={'test':[{'test':Decimal(1.24)}]})
self.assertEqual({'test':[{'test':Decimal(1.24)}]}, Test.objects.get(pk=t3.pk).json)
self.assertEqual({'test':[{'test':dec_str}]}, Test.objects.get(pk=t3.pk).json)

def test_time(self):
now = datetime.datetime.now().time()
Expand Down

0 comments on commit 7ca9df4

Please sign in to comment.