Ticket #6501: models.py

File models.py, 716 bytes (added by Moof, 17 years ago)

Failing tests for Decimal

Line 
1from django.db import models
2from decimal import Decimal
3
4class Foo(models.Model):
5 """ A test class, to check DecimalField works
6 >>> type(Decimal('0.00'))
7 <class 'decimal.Decimal'>
8
9 This fails, however:
10 >>> f = Foo()
11 >>> type(f.decimal)
12 <class 'decimal.Decimal'>
13
14 I get a unicode string instead
15 Expected:
16 <class 'decimal.Decimal'>
17 Got:
18 <type 'unicode'>
19
20 Workaround: you can save and reload it:
21 >>> f.save()
22 >>> g = Foo.objects.get(id=f.id)
23 >>> type(g.decimal)
24 <class 'decimal.Decimal'>
25 """
26
27 decimal = models.DecimalField(decimal_places=2, max_digits=10, default=Decimal("0.00"))
28
Back to Top