Home > Mobile >  django-bootstrap5 and button alignment
django-bootstrap5 and button alignment

Time:12-15

I want to display a button next to a form instead of below:

This is how it looks:

enter image description here

should look like this:

enter image description here

corresponding code:

form:

class TheForm(forms.Form):
    var = forms.ChoiceField(choices = choices, label = "")

temp

late:

{% if TheForm %}
    <form method = "post">
        {% csrf_token %}
        {% bootstrap_form TheForm %}
        {% bootstrap_button button_type="submit" content="OK" %}
    </form>
 {% endif %}

CodePudding user response:

Try bootstrap Grid system,

template.html

{% if TheForm %}
    <form method = "post">
        {% csrf_token %}
        <div > <!-- creates a row of 12 parts -->
            <div > <!-- Creates a column with width of 9 parts out of the above 12 parts -->
                {% bootstrap_form TheForm %}
            </div>
            <div >  <!-- Creates a column with width of remaining 3 parts out of the above 12 parts -->
                {% bootstrap_button button_type="submit" content="OK" %}
            </div>
        </div>
    </form>
 {% endif %}
  • Related