How can I access the form submit button value in Django?

Submit is an HTML Form structure… You must use name attribute of form objects as follows… In your template:

<form>
...
<input type="submit" name="list" value="List Objects" />
</form>
<form>
...
<input type="submit" name="do-something-else" value="Do Something Else" />
</form>

In your view:

if 'list' in request.POST:
    # do some listing...
elif 'do-something-else' in request.POST:
    # do something else

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)