forms.py 487 B

123456789101112131415
  1. import wtforms.validators
  2. from flask_wtf_alchemy_utils import ModelForm
  3. from flask_wtf.file import FileField, FileAllowed
  4. from foo.models import Thingy
  5. from foo.uploads import thingy_image
  6. class ThingySaveForm(ModelForm):
  7. class Meta:
  8. model = Thingy
  9. only = ('image',)
  10. image = FileField(validators=[FileAllowed(thingy_image, 'Only image files (gif, jpg, png) can be uploaded for this field')])
  11. image_delete = wtforms.BooleanField(label='Delete this image')