pallets-eco / pallets-eco/wtforms
`DecimalField` storing an `<input type="text">` and no quantize/round
Open
Nobody has claimed this yet.
breaking change
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 409
- PR merge metrics
- No merged PRs in 30d
Description
from flask.ext.wtf import Form
from wtforms import DecimalField
import decimal
class InputDecimal(Form):
price = DecimalField('price', places=2, rounding=decimal.ROUND_HALF_EVEN)
submit = SubmitField('Submit')
# When instantiated it stores text instead of a number
form = InputDecimal()
if form.validate_on_submit():
print(form.price)
print(form.price.data)
# the print at runtime
<input id="price" name="price" type="text" value="999.999">
999.999
# There is no rounding/quantize of the value.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the DecimalField entry point and trace how its submitted value is converted and rendered; compare the behavior with the places and rounding arguments in the example. Check existing field tests and add coverage showing the expected numeric value and rounded output for 999.999 with two places.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100