0

I'm running Django 1.9 with Bootstrap. I use pure Django, without any crispy forms etc. Some time ago I was struggling with forms customization under Bootstrap. My friend proposed me a solution. It's working, but for me it looks really heavy.

Is there any other, simpler way to make use of Django and Bootstrap forms? What I need, is to populate values in form and send them successfuly to Django backend.

<div class="form-group row">
    <label for="price" class="form-control-label col-md-3">Price</label>
    <div class="col-md-9">
        <input type="number" class="form-control"
               value="{{ form.price.data|default:''  }}" 
               name='price' id='price' placeholder="Price">
    </div>
</div>

1 Answer 1

1

You can render your {{ form }} by each field in html form, whith bootstrap classes like in this example:

<form action="" method="post">
    <div class="row">
        <div class ="col-md-6">{{ form.your_first_field }}</div> 
        <div class = "col-md-6">{{ form.your_second_field }}</div> 
    </div>
    <input type="submit" class="btn btn-primary"/>
</form>

Or you can try another layout, follow by this logic

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.