Getting MultiValueDictKeyError

37 views
Skip to first unread message

Sipum

unread,
May 16, 2019, 8:34:56 AM5/16/19
to Django users
Hi Friends,

when retrieving file that is uploaded , I'm getting multiValueDictKeyError.
Below are my codes. I have proided some codes where I m getting error. 
could anyone help me here ?

views.py
-------------

def webform_submit(request):
    if request.method =='POST':
        name = request.POST['name']
        email = request.POST['email']
        phone = request.POST['phone']
        job_title = request.POST['job_title']
        resume = request.FILES['document']                   -- getting error here 

        user_info = UserField(name = name, email = email, phone = phone,
                              job_title = job_title, resume = resume)
        user_info.save()
        messages.success(request,"Congrats!! Form is successfully saved in DB")
        return render(request, 'html/form.html', {})


form.html
------------------
                                      </div>
<label>Job title</label>
<input type="text" name="job_title" placeholder="Job Title" required>

<div class="form-group">
    <label for="exampleFormControlFile1">Resume</label>
    <input type="file" name="document" class="form-control-file" id="exampleFormControlFile1">
  </div>
<input type="submit" value="Submit">
</form>

thank you.

Test Bot

unread,
May 16, 2019, 9:12:29 AM5/16/19
to django...@googlegroups.com
Try putting encrypt="multipart/form-data" in your form tag

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/37a3ca49-6410-420f-a6a6-23bcf8e3f983%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sipum Mishra

unread,
May 16, 2019, 10:55:36 AM5/16/19
to django...@googlegroups.com
Hi friends, still getting same error after using encrypt..

Bt if i am using request. POST. get('document') then error vanishes but another error comes as job_title is an invalid keyword argument for this function.

Kindly help on this issue. I m trying hard but unable to solve.

Thanks 

Reply all
Reply to author
Forward
0 new messages