[Fixed]-List item template Django

1👍

You just need to change the code a bit is all:

{% for field in form %}
    { field.label }}: {{ field}}
    <input type="submit" class="btn btn-default btn-success" name="deployButton" value="Deploy"/>
    <input type="submit" class="btn btn-default btn-danger" name="undeployButton" value="Undeploy"/>
    <br />
{% endfor %}

So this will create a new line for each of the field.label and field variables with their own button. One thing to caution against though, if you try and assign ID’s to the buttons they will have to be different or you’ll get errors. Also, submission may be a bit weird with code such as this but it depends on the rest of your application. Either way, this will give you the desired format.

Leave a comment