У меня есть код html, в котором мне нужно узнать какую кнопку нажал пользователь и сделать определенные действия. HTML:
<div class="w3-show-inline-block">
<div class="w3-bar">
<h4 class="w3-wide">Сортировать по:
<button name="sort_complexity_ascending" class="w3-button w3-black">сложности от 1 до 5</button>
<button name="sort_complexity_descending" class="w3-button w3-black">сложности от 5 до 1</button>
<button name="sort_alphabet_ascending" class="w3-button w3-black">алфавиту от А до Я</button>
<button name="sort_alphabet_descending" class="w3-button w3-black">алфавиту от Я до А</button></h4>
</div>
</div>
views.py:
if request.method == 'GET':
if request.GET.get("sort_alphabet_ascending"):
history = sort_alphabet_ascending(history)
elif request.GET.get("sort_alphabet_descending"):
history = sort_alphabet_descending(history)
elif request.GET.get("sort_complexity_descending"):
history = sort_complexity_descending(history)
elif request.GET.get("sort_complexity_ascending"):
history = sort_complexity_ascending(history)