Hi,
I have this form which has a couple of form items and a file upload.
Now as long as I select an image to be uploaded the form works fine
and the data is saved, however, when you try to submit the form
without uploading an image I land up getting the error
Exception Type: MultiValueDictKeyError
Exception Value:
"Key 'uploadphoto' not found in <MultiValueDict: {}>"
My code looks something like this
if request.FILES['uploadphoto']:
up = request.FILES['uploadphoto']
upn =
up.name
handle_uploaded_file(up)
photo = upn
and in trace back the error is on this line "up =
request.FILES['uploadphoto'] "
How do I write an if statement where I can check if the request.FILES
is not empty then execute the below statements
Thanks for your help in advance
J