Improved XML format check

This commit is contained in:
Marcin Armacki 2020-05-22 10:58:57 +02:00
parent f95c010cad
commit 01e33bd2df

View File

@ -21,11 +21,12 @@ def model_form_upload(request):
return HttpResponse('Niepoprawny format XML', status=406)
form = DocumentForm(request.POST, request.FILES)
print("POST: " + str(request.POST))
print("FILES: " + str(request.FILES))
try:
data = parseData(request.FILES['file'])
except:
return HttpResponse('Niepoprawny format XML', status=406)
if form.is_valid():
form.save()
data = parseData(request.FILES['file'])
return JsonResponse(data, safe=False)
else:
form = DocumentForm()