Skip to content

DecimalField's validate_precision incorrectly calculates total_digits for decimals smaller than 1 #9762

Discussion options

You must be logged in to vote

The argument is called max_digits, not significant_digits, and I'm not sure where you got the "significant digits" from, but I don't think it's ever mentioned as such in our docs? That may be an important concept for decimal/scientific notation more generally, but it's not really what we're talking about here.

I think the whole point is to have:

  • max_decimal_places: how many number can be after the decimal: (XXX.XX -> max_decimal_places = 2)
  • max_digits: maximum number of digits, whole + decimal (XXX.XX -> max_digits = 5)
  • this set the max_whole_digits to 3 here

Also, this test pass now, so the value is now validated correctly (yes, to_internal_value takes a string and returns a Decimal):

d…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@browniebroke
Comment options

Answer selected by mahdirahimi1999
@mahdirahimi1999
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants