Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask_wtf import FlaskForm
- from wtforms import StringField, DateTimeField, BooleanField, SubmitField
- from wtforms.validators import DataRequired, ValidationError
- from datetime import datetime
- class TodoForm(FlaskForm):
- title = StringField("Tytuł", validators=[DataRequired()])
- due_date = DateTimeField("Termin", format="%Y-%m-%d %H:%M:%S", validators=[DataRequired()])
- completed = BooleanField("Wykonane")
- submit = SubmitField("Zapisz")
- def validate_due_date(form, field):
- if field.data <= datetime.now():
- raise ValidationError("Data i czas muszą być późniejsze niż teraz.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement