[Answer]-I get error MultiValueDictKeyError if I dont upload all 3 filefields in my django form

1👍

newdoc = Document(docfile = request.FILES['docfile'])
...

newdoc = Document(docfile1 = request.FILES['docfile1'])
...

newdoc = Document(docfile2 = request.FILES['docfile2'])

This will raise a MultiValueDictKeyError if the key doesn’t exist. Use request.FILES.get() with a default value.

👤knbk

Leave a comment