есть html-страничка с формой (bootstrap5) и кнопка для отправки, но во views.py запрос прилетает без полей формы. Код views.py
@require_http_methods(['GET', 'POST'])
def new_record(request):
record_item = Record()
#record_item.save()
if request.method == "GET":
new_rec_form = NewRecordForm([record_item], initial={'id': record_item.id})
if request.method == "POST":
print(request.POST)
new_rec_form = NewRecordForm([record_item], data=request.POST, initial={'id': record_item.id})
if new_rec_form.is_valid():
#print("valid")
return redirect(reverse('index'))
#else:
#print(new_rec_form.errors)
#print("not valid")
#emp =
#record_item.employer = request.POST.get("employer")
context = {'record': record_item, 'form': new_rec_form}
return render(request, 'new_record.html', context=context)
Код формы:
<form action="/new_record/" method="post" id="id_NewRecordForm" class="row" data-url="{% url 'ajax_load_data' %}">
{% csrf_token %}
<div class="row">
<div class="col-6">
<div class="row rec_row">
<div class="col-2">
{% bootstrap_field form.id %}
</div>
<div class="col-10">
{% bootstrap_field form.serial_number %}
</div>
</div>
<div class="row rec_row">
<div class="col-6">
{% bootstrap_field form.inv_number %}
</div>
<div class="col-6">
{% bootstrap_field form.acc_inv_number %}
</div>
</div>
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.batch %}
</div>
</div>
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.type %}
</div>
</div>
<div class="row rec_row model_select">
<div class="col-12">
{% bootstrap_field form.model %}
</div>
</div>
</div>
<div class="col-6">
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.company %}
</div>
</div>
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.office %}
</div>
</div>
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.cabinet %}
</div>
</div>
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.status %}
</div>
</div>
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.employer %}
</div>
</div>
</div>
<div class="col-12">
<div class="row rec_row">
<div class="col-12">
{% bootstrap_field form.description %}
</div>
</div>
</div>
<div class="col-1 buttons">
<button type="button" id="change_button" class="btn btn-primary" onclick="change_data()">Сохранить
</button>
</div>
<div class="col-1 buttons">
<button type="submit" id="send_button" class="btn btn-primary" disabled>Отправить</button>
</div>
</div>
</form>
В коде страницы у тега input есть аттрибуты name, но в теле POST-запрос их нет. Вывод в консоли
<QueryDict: {'csrfmiddlewaretoken': ['39lGQ3eBCggi9hkzaMTmu4mQVHHcgeCa0TzPK5BQgNGW5FHLonq3znYkGNAiMLSX']}>
[04/Jan/2023 18:37:41] "POST /new_record/ HTTP/1.1" 200 12138