Python Flask WT-Forms Demo: Numeric Input (IntegerField and DecimalField)

Published: 17 July 2023
on channel: Thomas Blum
298
5

In this video we continue to demo basic WT-Forms in a Python-Flask app. This time we add numeric inputs. In WT-Forms this is accomplished with IntegerField and DecimalField, both of which result in HTML inputs of the numeric type when the form HTML is rendered. In the example the two new fields allow a user to enter an hourly wage and a number of hours worked in a week. In addition to displaying the information entered, it is used to calculate the weekly salary (including time-and-a-half for overtime hours exceeding 40 hours). We show how the calculation can be performed using Python as the routing Python/Flask passes the data from the form HTML to the handler HTML (the calculated salary is passed as an argument in render_template for the handler). We also show how the calculation can be performed using Jinja. The data must be cast into the appropriate type and we need an if control structure within Jinja to test whether the user worked overtime or not.


On this page of the site you can watch the video online Python Flask WT-Forms Demo: Numeric Input (IntegerField and DecimalField) with a duration of hours minute second in good quality, which was uploaded by the user Thomas Blum 17 July 2023, share the link with friends and acquaintances, this video has already been watched 298 times on youtube and it was liked by 5 viewers. Enjoy your viewing!