I am trying to validate a field. In models.py I have:
db.define_table(
"weather",
Field("temp"),
etc.
)
db.weather.temp.requires = IS_EMPTY_OR(
IS_DECIMAL_IN_RANGE(-99, 99, dot=".", error_message='must be empty or a number from -99 to 99'))
The problem I have is that by introducing that validation the form displays '0.00' by default
whereas I want it to display nothing (and then by allowing that default of 0.00 to post it
results in 0.00 being posted to the underlying table - as expected).
In other words, I want the user to be able to enter a decimal from -99..0..99, and I want to validate any entry they do make, but I also want to be able to post NULL if they do not enter anything themselves.
(I confirm that the underlying mariadb table will accept NULL in the corresponding decimal field. I also confirm that I am new to py4web and python!)
Many thanks
Max