Я пытаюсь заставить Django отправить форму с элементом <a>
, но вместо этого используется метод add_employee_action()
GET
POST
<form id="add-employee-form" action="add/" method="POST">
<table>
<tr>
<th class="table-title" id="second-name">
Фамилия
</th>
<th class="table-title" id="first-name">
Имя
</th>
<th class="table-title" id="patronymic">
Отчество
</th>
<th class="table-title" id="birth-date">
Дата рождения
</th>
</tr>
<tr>
<th id="second-name">
<div class="field-wrapper">
{{ form.second_name.errors }}
{{ form.second_name }}
</div>
</th>
<th id="first-name">
<div class="field-wrapper">
{{ form.first_name.errors }}
{{ form.first_name }}
</div>
</th>
<th id="patronymic">
<div class="field-wrapper">
{{ form.patronymic.errors }}
{{ form.patronymic }}
</div>
</th>
<th id="birth-date">
<div class="field-wrapper" id="birth-date-wrapper">
{{ form.birth_date.errors }}
{{ form.birth_date }}
</div>
</th>
</tr>
</table>
{% csrf_token %}
<div class="button_bar">
<a class="a-button positive" href="{% url 'add-employee-action' %}">Добавить</a>
<a class="a-button" href="{% url 'employee' %}">Сотрудники</a>
<a class="a-button" href="{% url 'index' %}">На главуную</a>
</div>
</form>
urls.py
path('employee/add_employee/add/', views.add_employee_action, name='add-employee-action'),
views.py
def add_employee_action(request):
if request.method == "POST":
form = AddEmployeeForm(request.POST)
if form.is_valid():
form.save()
else:
form = AddEmployeeForm()
context = {
'form': form,
}
return render(request, 'add_employee.html', context)
Как отправить форму с использованием элемента <a>
?