I use django to build my web app. And one of the page sends different files (with different file types). I have 6 file type. And my current version of code (it's really bad - that is why I write this question) is:
try:
file = request.FILES[u'file_doc']
except MultiValueDictKeyError:
try:
file = request.FILES[u'file_fb2']
except MultiValueDictKeyError:
try:
file = request.FILES[u'file_pdf']
except MultiValueDictKeyError:
try:
file = request.FILES[u'file_txt']
except MultiValueDictKeyError:
try:
file = request.FILES[u'file_other']
except MultiValueDictKeyError:
try:
file = request.FILES[u'file_chm']
except MultiValueDictKeyError:
return HttpResponse('bad file type')
Could you advise me - how to improve this bad peace of code.
TIA!