dimanche 11 février 2018

How to use bootstrap checkbox control in django

I am using check box control in a simple django application. When I use the standard check box control, I can get the desired values in views.py. But I fail to get the values when I use bootstrap check box control. Logic seems to be fine, I don't know why it's not working. Can anybody point out the mistake, Thanks in advance.

Standard Way

<input type="checkbox" name="fruit" value="Apple"> Apple 
<input type="checkbox" name="fruit" value="Mango"> Mango

Bootstrap Way

<div class="form-check">
    <input class="form-check-input" type="checkbox" value="" id="fruit">
    <label class="form-check-label" for="fruit">Apple</label>
</div>
<div class="form-check">
    <input class="form-check-input" type="checkbox" value="" id="fruit">
    <label class="form-check-label" for="fruit">Mango</label>
</div>

view.py

if request.method == 'POST':
        fruit = request.POST.getlist('fruit')




Aucun commentaire:

Enregistrer un commentaire