[Answer]-Python requests module not able to upload file on django server

1👍

I think the problem here is the name of file element. It should be docfile. In curl example you have passed that as docfile but in the python script you left it as file.

Alter this line:

files = {'file': open('file.ext', 'rb')}

to this:

files = {'docfile': open('file.ext', 'rb')}

0👍

When you look at the request in your view you may see it in request.FILES[‘file’]
I had a problem because I was had a bad setting in a headers file.

Leave a comment