Request.POST не определяет имя поля ввода
Я хотел бы узнать, какая форма была отправлена в django, и я сделал это, используя имя поля ввода и определяя его, если оно также является именем в request.POST. Однако, похоже, это не работает.
HTML
<input type="file" name="coverPhoto" accept="image/*" id="id_coverPhoto">
<input type="file" name="profilePic" accept="image/*" id="id_profilePic">
views.py
if request.method == 'POST':
if 'profilePic' in request.POST:
profile_photo_form = ProfileForm(request.POST, request.FILES, instance=user)
if profile_photo_form.is_valid():
profile = profile_photo_form.save(commit=False)
profile.save()
return HttpResponseRedirect(reverse("my-profile"))
if 'coverPhoto' in request.POST:
cover_photo_form = CoverPhotoForm(request.POST, request.FILES, instance=user)
if cover_photo_form.is_valid():
cover = cover_photo_form.save(commit=False)
cover.save()
return HttpResponseRedirect(reverse("my-profile"))