0

When working in Django,

Both name="button" and name="submit" work properly when I submit the form

    {% buttons %}
        <button name="button" class='btn btn-primary'>Save</button>
    {% endbuttons%}
    {% buttons %}
        <button name="submit" class='btn btn-primary'>Save</button>
    {% endbuttons%}

What's the difference between button and submit

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
  • 1
    Possible duplicate of [Difference between and ](https://stackoverflow.com/questions/290215/difference-between-input-type-button-and-input-type-submit) – Thiago Mata May 24 '18 at 01:42
  • my question is not about type. @ThiagoMata – AbstProcDo May 24 '18 at 02:02
  • Do you have Javascript in your form? Which browser are you using? – Lex May 24 '18 at 03:01
  • Use `google chrome` and import `bootstrap3` @Lex don't have Js in my form. – AbstProcDo May 24 '18 at 03:05
  • According to MDN [type button](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) has no default behaviour . I could be the browser still interprets the button as a submit action; Or there is js adding a submit action on the button – Lex May 24 '18 at 03:05
  • 1
    Yeah the browser assumes its Submit https://stackoverflow.com/questions/3403415/google-chrome-submits-form-even-if-there-is-no-submit-button – Lex May 24 '18 at 03:06
  • amazing, I am unable to upvote your comments with 3 reputations, could you please transmit your comments to the answer. @Lex – AbstProcDo May 24 '18 at 03:37

2 Answers2

0
<input type="button" /> 

buttons will not submit a form - they don't do anything by default, this is usually used along with JS to make some form of request or call a function.

<input type="submit">

this will submit the form that the input is within when it is clicked by default.

sjdm
  • 591
  • 4
  • 10
0

I think you want to use type attribute, ie: type="button" and type="submit", rather than the name attribute.

bkupfer
  • 124
  • 11