pallets-eco / pallets-eco/wtforms

`DecimalField` storing an `<input type="text">` and no quantize/round

Open
#101 5 comments 3 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.