I am new to python and programming in general.
I keep getting UploadNotAllowed
error even though I set the form field validator to Optional()
. My goal is to allow users the choice of uploading or not uploading a profile picture. All configurations work well when an image if selected to be uploaded.
Any help will be appreciated.
Here is the form field:
class SettingsForm(FlaskForm):
profile_pic = FileField('Profile Picture', validators= [Optional(), FileAllowed(images, 'Only images are allowed here')])
Here is my views.py:
if form.validate_on_submit():
filename = images.save(request.files['profile_pic'])
current_user.profile_pic = images.url(filename)