[Solved]-Differentiating between different post requests on the same page in Django views.py


Submit buttons in HTML have name and value properties. For example if you have:

    <input type="submit" name="action" value="Send"/>
    <input type="submit" name="action" value="Hello"/>

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

Leave a comment