I can’t seem to recognize the problem in my django project – I have a simple form with 2 "input" tags and I can’t identify in my code which one is being pressed.
front end:
<form method="POST">
{% csrf_token %}
<input type="image" value="accept" class="v" src="{% static 'main/assets/icons/v.png' %}">
<input type="image" value="decline" class="x" src="{% static 'main/assets/icons/x.png' %}">
</form>
back end:
if response.method == "POST":
if response.POST.get("accept"):
return render(response, "main/calender-page.html", {})
if response.POST.get("decline"):
return render(response, "main/account-page.html", {})
I tried to search for answers in stack overflow and I never managed to find one that works.
Thanks for the help!
3
Answers
add name=’accept’ and try again:
you need html tag attribute ‘name’ to identify POST data key.
i think u need radio input.
front end:
back end: