Skip to content Skip to sidebar Skip to footer

WTForms Not Validating NumberRange

I'm making a WTForm which takes Decimals as inputs, and I'm trying to restrict input to a range of numbers (between 0 and 10 inclusive). However, the validator NumberRange doesn't

Solution 1:

Apparently your application is not correctly configured. The code should look like this:

from flask_wtf import FlaskForm
from wtforms import SubmitField, DecimalField
from wtforms.validators import NumberRange

class NumberForm(FlaskForm):
    question = DecimalField('Question 1', validators=[NumberRange(min=0, max=10, message='bla')])
    submit = SubmitField('Submit')

Post a Comment for "WTForms Not Validating NumberRange"