18👍
✅
Submit buttons in HTML have name and value properties. For example if you have:
<form>
<input type="submit" name="action" value="Send"/>
<input type="submit" name="action" value="Hello"/>
</form>
Then in Django you can distinguish the two submit actions by the value of action
:
if request.POST['action'] == 'Send':
# do this
elif request.POST['action'] == 'Hello':
# do that
Source:stackexchange.com