2
from django.db import models
7
from django.utils import _decimal as decimal # Python 2.3 fallback
9
class Foo(models.Model):
10
a = models.CharField(max_length=10)
11
d = models.DecimalField(max_digits=5, decimal_places=3)
14
return Foo.objects.get(id=1)
16
class Bar(models.Model):
17
b = models.CharField(max_length=10)
18
a = models.ForeignKey(Foo, default=get_foo)
20
class Whiz(models.Model):
34
c = models.IntegerField(choices=CHOICES, null=True)
36
__test__ = {'API_TESTS':"""
37
# Create a couple of Places.
38
>>> f = Foo.objects.create(a='abc', d=decimal.Decimal("12.34"))
41
>>> b = Bar(b = "bcd")
46
# Regression tests for #7913
47
# Check that get_choices and get_flatchoices interact with
48
# get_FIELD_display to return the expected values.
56
# Test a top level value
61
# Test an invalid data value
66
# Test a blank data value
68
>>> print w.get_c_display()
71
# Test an empty data value
76
# Regression test for #8023: should be able to filter decimal fields using
77
# strings (which is what gets passed through from, e.g., the admin interface).
78
>>> Foo.objects.filter(d=u'1.23')