1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

Fixed #7064: Made DemicmalField validation support max_digits equal to decimal_places.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9387 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey
2008-11-10 19:52:53 +00:00
parent 8cdc53a265
commit d82aaef844
2 changed files with 13 additions and 12 deletions

View File

@@ -254,12 +254,12 @@ class DecimalField(Field):
decimals = abs(exponent)
# digittuple doesn't include any leading zeros.
digits = len(digittuple)
if decimals >= digits:
if decimals > digits:
# We have leading zeros up to or past the decimal point. Count
# everything past the decimal point as a digit. We also add one
# for leading zeros before the decimal point (any number of leading
# whole zeros collapse to one digit).
digits = decimals + 1
# everything past the decimal point as a digit. We do not count
# 0 before the decimal point as a digit since that would mean
# we would not allow max_digits = decimal_places.
digits = decimals
whole_digits = digits - decimals
if self.max_value is not None and value > self.max_value: