diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-07-30 00:18:49 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-07-30 00:18:49 +0000 |
| commit | 281f2b74bf19161a0dc5791a07d239ce6a27ed2f (patch) | |
| tree | 1c37103e4c6bd691c9d564231222e412ad7a6d26 /tests | |
| parent | 1ba2d6888f78ddd280d5882cd31e7253ef143cbc (diff) | |
Fixed #8023 -- Allow filtering of DecimalFields (in models) using strings.
At the same time, checked all other cases of db_prep_value() to ensure they
aren't making the same mistake.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8143 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/model_fields/models.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/regressiontests/model_fields/models.py b/tests/regressiontests/model_fields/models.py index 790bc5010e..455e2b3ded 100644 --- a/tests/regressiontests/model_fields/models.py +++ b/tests/regressiontests/model_fields/models.py @@ -1,8 +1,14 @@ from django.db import models +try: + import decimal +except ImportError: + from django.utils import _decimal as decimal # Python 2.3 fallback + class Foo(models.Model): a = models.CharField(max_length=10) + d = models.DecimalField(max_digits=5, decimal_places=3) def get_foo(): return Foo.objects.get(id=1) @@ -22,14 +28,14 @@ class Whiz(models.Model): (3,'Third'), (4,'Fourth'), ) - ), + ), (0,'Other'), ) c = models.IntegerField(choices=CHOICES, null=True) - + __test__ = {'API_TESTS':""" # Create a couple of Places. ->>> f = Foo.objects.create(a='abc') +>>> f = Foo.objects.create(a='abc', d=decimal.Decimal("12.34")) >>> f.id 1 >>> b = Bar(b = "bcd") @@ -67,5 +73,10 @@ None >>> w.get_c_display() u'' +# Regression test for #8023: should be able to filter decimal fields using +# strings (which is what gets passed through from, e.g., the admin interface). +>>> Foo.objects.filter(d=u'1.23') +[] + """} |
