Project 4: Movie Watchlist: Creating a form with WTForms (+19, -0)
forms.py (+19, -0)
From:
curriculum/section14/lectures/06_create_form_with_wtforms/end/movie_library/forms.py
To:
curriculum/section14/lectures/06_create_form_with_wtforms/end/movie_library/forms.py
new file mode 100644
index 0000000..b22bb36
--- /dev/null
+++ b/curriculum/section14/lectures/06_create_form_with_wtforms/end/movie_library/forms.py
@@ -0,0 +1,19 @@
+from flask_wtf import FlaskForm
+from wtforms import IntegerField, StringField, SubmitField
+
+from wtforms.validators import InputRequired, NumberRange
+
+
+class MovieForm(FlaskForm):
+ title = StringField("Title", validators=[InputRequired()])
+ director = StringField("Director", validators=[InputRequired()])
+
+ year = IntegerField(
+ "Year",
+ validators=[
+ InputRequired(),
+ NumberRange(min=1878, message="Please enter a year in the format YYYY."),
+ ],
+ )
+
+ submit = SubmitField("Add Movie")