Skip to content

DecimalField precision is ignored in wtforms, defaults to 2 #341

Closed
@PeterKharchenko

Description

@PeterKharchenko

Wtform's DecimalField "places" attribute defaults to 2, disregarding mongoengine's DecimalField "precision" attribute.
One of the negative scenarios - if the document is edited by user using wtform (say, some other field is edited), decimal value is rounded to 2 places and data is lost.

Solved it by replacing

return f.DecimalField(**kwargs)

with

return f.DecimalField(places=getattr(field, 'precision', None),**kwargs)

in wtf/orm.py, line 148

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions