Advertisement
ksieradzinski

Untitled

Feb 28th, 2025
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. from flask_wtf import FlaskForm
  2. from wtforms import StringField, DateTimeField, BooleanField, SubmitField
  3. from wtforms.validators import DataRequired, ValidationError
  4. from datetime import datetime
  5.  
  6. class TodoForm(FlaskForm):
  7. title = StringField("Tytuł", validators=[DataRequired()])
  8. due_date = DateTimeField("Termin", format="%Y-%m-%d %H:%M:%s", validators=[DataRequired()])
  9. completed = BooleanField("Wykonane")
  10. submit = SubmitField("Zapisz")
  11.  
  12. def validate_due_date(form, field):
  13. if field.date <= datetime.now():
  14. raise ValidationError("Data i czas muszą być późniejsze niż teraz.")
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement