HTML-форма не передает данные в Django views.py, передается нулевая строка

Я пытался создать многошаговую форму и при отправке формы передается значение по умолчанию из тега select и пустая строка из тега input. И поэтому преобразование в целое число в views.py показывает ошибку значения. Я добавил атрибут name в html-форму, но значения не передаются. Может ли кто-нибудь помочь мне, что я упустил?

HTML

JavaScript

 const steps = Array.from(document.querySelectorAll("form .step"));
const nextBtn = document.querySelectorAll("form .next-btn");
const prevBtn = document.querySelectorAll("form .previous-btn");
const form = document.querySelector("form");

nextBtn.forEach((button) => {
  button.addEventListener("click", () => {
    changeStep("next");
  });
});
prevBtn.forEach((button) => {
  button.addEventListener("click", () => {
    changeStep("prev");
  });
});

form.addEventListener("submit", (e) => {
  const inputs = [];
  form.querySelectorAll("input").forEach((input) => {
    const { name, value } = input;
    inputs.push({ name, value });
  });
  console.log(inputs);
  form.reset();
  return true;
});

function changeStep(btn) {
  let index = 0;
  const active = document.querySelector(".active");
  index = steps.indexOf(active);
  steps[index].classList.remove("active");
  if (btn === "next") {
    index++;
  } else if (btn === "prev") {
    index--;
  }
  steps[index].classList.add("active");
}

views.py

 def automated_consultancy(request):
    return render(request, 'start/automated_consultancy.html')

def estimated_cost(request):
    if request.method == 'POST':
        types = int(request.POST.get('type'))
        purpose =int(request.POST.get('purpose'))
        quantity = int(request.POST.get('quantity'))
        length = int(request.POST.get('x'))
        width = int(request.POST.get('y'))
        depth = int(request.POST.get('z'))
        budget = int(request.POST.get('budget'))
        
        print(types,purpose, budget, quantity, length, width, depth)
Вернуться на верх