Ticket #5079: 5079.diff
File 5079.diff, 1.1 KB (added by , 17 years ago) |
---|
-
tests/modeltests/basic/models.py
6 6 """ 7 7 8 8 from django.db import models 9 from decimal import Decimal 9 10 10 11 class Article(models.Model): 11 12 headline = models.CharField(max_length=100, default='Default headline') … … 17 18 def __unicode__(self): 18 19 return self.headline 19 20 21 class DecimalTest(models.Model): 22 field = models.DecimalField(max_digits=40, decimal_places=1) 23 20 24 __test__ = {'API_TESTS': """ 25 >>> b1 = DecimalTest(field=Decimal(".1")) 26 >>> b1.field 27 Decimal("0.1") 28 >>> b1.save() 29 >>> b1.field 30 Decimal("0.1") 31 >>> b1 = DecimalTest.objects.get(id=1) 32 >>> b1.field 33 Decimal("0.1") 34 >>> b1.field = Decimal(".14") 35 36 # the value is still .14 before saving 37 >>> b1.field 38 Decimal("0.14") 39 >>> b1.save() 40 41 # but when we save/retrieve from the DB the constraints have been applied 42 >>> b1 = DecimalTest.objects.get(id=1) 43 >>> b1.field 44 Decimal("0.1") 45 21 46 # No articles are in the system yet. 22 47 >>> Article.objects.all() 23 48 []