[Answered ]-Can not add bootstrap class with button using Django and Python

2👍

Having the same attribute twice on an element (e.g. class) is invalid HTML. Instead of

<button class="buttondiv" name="strt" type="submit" class="btn btn-success">Start</button>
<button class="buttondiv" name="shutbt" type="submit" class="btn btn-danger">Shut Down</button>
<button class="buttondiv" name="susbtn" type="submit" class="btn btn-info">Suspend</button>

go for

<button class="buttondiv btn btn-success" name="strt" type="submit">Start</button>
<button class="buttondiv btn brn-danger" name="shutbt" type="submit">Shut Down</button>
<button class="buttondiv btn btn-info" name="susbtn" type="submit">Suspend</button>

On a sidenote:

You might want to rename your CSS classes. buttondiv is very HTML-centric and leaks its scope (button in a div). A better approach is usually to either use element-type selectors (e.g. div button) or use more domain related terms for CSS classes (e.g. call-to-action or entry-operation). This will help you later on whenever you want to apply the same style elsewhere or introduce other classes with similar scope.

Same goes for the element names here, which seem to be lacking consistency.

Leave a comment