Why come out this error " raise MultiValueDictKeyError(key) django.utils.datastructures.MultiValueDictKeyError: 'file'"?

Pleeease reply what is the problem (
def signupp(request):
 if request.method == 'POST':
 user = User.objects.create_user(username=request.POST['name'], password=request.POST['pin'])
 number = request.POST['number']
 fname = request.POST['fname']
 lname = request.POST['lname']
 address = request.POST['address']
 birtday = request.POST['birtday']
 passport = request.POST['passport']
 number_pass = request.POST['number_pass']
 body_pass = request.POST['body_pass']
 file = request.POST['file']
 role = request.POST['role']
 new = Register(number=number,fname=fname,lname=lname,address=address,birtday=birtday,passport=passport,number_pass=number_pass,
 auth.login(request, user)
 return HttpResponse("Signed Up")
 return render(request, 'registration/registration.html')

<form action="{% url 'sign' %}" method="post" enctype="multipart/form-data">
 {% csrf_token %}
 <input type="text" name="number">
 <input type="text" name="fname">
 <input type="text" name="name">
 <input type="text" name="lname">
 <input type="text" name="address">
 <input type="date" name="birtday">
 <input type="text" name="passport">
 <input type="text" name="number_pass">
 <input type="text" name="body_pass">
 <input type="password" name="pin" placeholder="pin">
 <input type="file" name="file">
 <input type="text" name="role">
<button type="submit" value="Signup" class="btn btn-outline-primary btn-block mb-5 ">Add</button>
April 19th 20 at 12:15
1 answer
April 19th 20 at 12:17
# on

that was another error? ;) You need not just to replace, but to handle empty values - Patricia.Jakubows commented on April 19th 20 at 12:20
How to transfer file came out again the error is
raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'file' - eudora.Pur commented on April 19th 20 at 12:23
@eudora.Pur, with the files of other work necessary.

from django.http import HttpResponseRedirect
from django.shortcuts import render
from .forms import UploadFileForm

# Imaginary function to handle an uploaded file.
from somewhere import handle_uploaded_file

def upload_file(request):
 if request.method == 'POST':
 form = UploadFileForm(request.POST request.FILES)
 if form.is_valid():
 return HttpResponseRedirect('/success/url/')
 form = UploadFileForm()
 return render(request, 'upload.html', {'form': form})
- isaias.Koch40 commented on April 19th 20 at 12:26
@isaias.Koch40, OK ATP I went) - eudora.Pur commented on April 19th 20 at 12:29

Find more questions by tags Django