problem in entering user's data

is have this method to handle data entered by a job seeker
the problem is whenever i want to change something like the seeker’s name without uploading a new cv file, i get error: MultiValueDictKeyError
‘’'@login_required(login_url=‘login’)
def editAccount(request):

if request.user.is_Seeker:
    seeker = request.user.seeker
    form = SeekerAccountForm(instance=seeker)
    

elif request.user.is_Recruiter:
    recruiter = request.user.recruiter
    form = RecruiterAccountForm(instance=recruiter)

    
AllSkills = []

if request.method == 'POST':
    if request.user.is_Seeker:
        form = SeekerAccountForm(request.POST, request.FILES, instance=seeker)
        if form.is_valid():
            # Validate file extension
           
            file = request.FILES['cv']
            if file:
                try:
                    # Validate the file extension
                    validate_word_or_text_file(file)
                    tokens = tokenize_cv(file)
                    major= 'Computer Science'
                    check_major(tokens, major ,seeker)
                except ValidationError as e:
                    form.add_error('cv', e)
                    messages.error(request, 'the cv format is not accepted, Try (.docx , .txt , .rtf)')
                    return render(request, 'account-edit.html', {'form': form})
            
            form.save()
            messages.success(request, 'Your account has been updated!')
            return redirect('account')
    elif request.user.is_Recruiter:
        form = RecruiterAccountForm(request.POST, request.FILES, instance=recruiter)
        if form.is_valid():
            form.save()
            messages.success(request, 'Your account has been updated!')
            return redirect('account')

context = {'form': form}
if request.user.is_Seeker and seeker is not None:
    context['cv_skills'] = AllSkills
return render(request, 'account-edit.html', context)'''

Note: Please remember to surround the code in your post between lines of three backtick - ` characters. (You must use the backtick - `, not the apostrophe - '.) Also, the three backticks must be lines by themselves and not part of other lines.

Please post the complete traceback you are receiving. (Also surrounded between lines of three backtick characters.)

1 Like