'MultiValueDictKeyError django, views.py error
I'm getting MultiValueDictKeyError while using the POST method with Django.
this is my views.py submit function. it seems like there is an error with the candidateId field and I don't understand why.
def submit_dept_member_application(request, application_id):
cv = request.FILES['cv']
letter = request.FILES['letter']
candidate_id = request.data['candidateId']
rank_id = request.data['requestedRankId']
application_state = {
'candidate_id': candidate_id,
'rank_id': rank_id,
'cv_filename': cv.name,
'letter_filename': letter.name,
}
creator = Profile.objects.get(user=request.user.id)
department = creator.department
applicant = Profile.objects.get(user=candidate_id)
rank = Rank.objects.get(id=rank_id)
try:
application = Application.objects.get(id=application_id)
# TODO - update application
except Application.DoesNotExist:
application = None
if application is None:
application = Application(creator=creator, applicant=applicant, desired_rank=rank,
application_state=application_state, department=department
)
application.save()
create_application_directory(application.id)
ApplicationStep.objects.update_or_create(
application=application, step_name=Step.STEP_1,
defaults={'can_update': True, 'can_cancel': True, 'currentStep': True}
)
copy_to_application_directory(cv, application.id)
copy_to_application_directory(letter, application.id)
addresee = '[email protected]' # TODO: change email to admin address
email_headline = 'New Application Created'
wanted_action = 'application_created'
sendEmail(addresee, email_headline, wanted_action, creator)
addresee = '[email protected]' # TODO: change email to creator address
email_headline = 'Application Successfully Created'
wanted_action = 'application_received'
sendEmail(addresee, email_headline, wanted_action, applicant)
return Response(application.id, status=status.HTTP_200_OK)
any suggestions on how to solve it? Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

