I have tried using Django-2.2.20 with the latest Uppy 1.27.0 and using XHR to send the file to my Django views.py
. However, the request.FILES[‘files’] is empty, means that the files is not sent to backend. I use Uppy.Dashboard too. Here is my code
1. general.html
let uppy = new Uppy.Core()
const Dashboard = Uppy.Dashboard
const Form = Uppy.Form
const XHRUpload = Uppy.XHRUpload
uppy.use(Dashboard, {
inline: true,
target: '#drag-drop-area',
showProgressDetails: true,
})
.use(XHRUpload, {
endpoint: './',
formData: true,
})
.use(Form, {
target: '#filesupload',
getMetaFromForm: true,
addResultToForm: true,
multipleResults: true,
submitOnSuccess: true,
triggerUploadOnSubmit: true
})
uppy.on('complete', (result) => {
console.log('Upload complete! We’ve uploaded these files:', result.successful)
})
</script>
2. views.py
class UploadView(View):
@method_decorator(login_required)
def post(self, request):
form = DataForm(self.request.POST, self.request.FILES)
select_project_id = request.POST['select-project'] # * (integer) 1, 2, etc.
board_version_id = request.POST['select-board-version'] # * (integer) 1, 2, etc.
station = request.POST['select-test-station'] # * Coreboard, Dotboard, LEDboard, etc..
part = request.POST['select-test-part'] # * data, log, ComportText, TelnetText, etc..
test_date, serial_number, result, error_code, error_code_desc = readDataFile(request.FILES['files'])
it gives me error MultiValueDictKeyError at /upload/ - files
means that files is empty. Really need your help!