Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Commit

Permalink
Remove case when last digit is ommited
Browse files Browse the repository at this point in the history
In case of:
	amount = models.DecimalField(
	    null=False,
	    max_digits=16,
	    decimal_places=2,
	    blank=False,
	)

Decimal(47461379535606.35)

converts to

Decimal('47461379535606.4')

What is not the best situation for testing. It seems that Django thinks about "." as a symbol that included into max_digits.
  • Loading branch information
yrik authored and vandersonmota committed Jul 25, 2015
1 parent 8156a4a commit e02e19f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion model_mommy/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def gen_float():

def gen_decimal(max_digits, decimal_places):
num_as_str = lambda x: ''.join([str(randint(0, 9)) for i in range(x)])
return Decimal("%s.%s" % (num_as_str(max_digits - decimal_places),
return Decimal("%s.%s" % (num_as_str(max_digits - decimal_places - 1),
num_as_str(decimal_places)))
gen_decimal.required = ['max_digits', 'decimal_places']

Expand Down

0 comments on commit e02e19f

Please sign in to comment.