lundi 6 février 2017

Django get values from bootstrap checkbox

I am trying to get values from bootstrap checkbox. Here is my fancy checkbox:

<div class="container">

    <div class="[ col-xs-12 col-sm-6] text-center">
        <div class="[ form-group ]">
            <input type="checkbox" name="fancy-checkbox-success-custom-icons" id="fancy-checkbox-success-custom-icons" autocomplete="off" />
            <div class="[ btn-group ]">
                <label for="fancy-checkbox-success-custom-icons" class="[ btn btn-success ]">
                    <span class="[ glyphicon glyphicon-plus ]"></span>
                    <span class="[ glyphicon glyphicon-minus ]"></span>
                </label>
                <label for="fancy-checkbox-success-custom-icons" class="[ btn btn-default active ]">
                    Nature
                </label>
            </div>
        </div>
        <div class="[ form-group ]">
            <input type="checkbox" name="fancy-checkbox-info-custom-icons" id="fancy-checkbox-info-custom-icons" autocomplete="off" />
            <div class="[ btn-group ]">
                <label for="fancy-checkbox-info-custom-icons" class="[ btn btn-info ]">
                    <span class="[ glyphicon glyphicon-plus ]"></span>
                    <span class="[ glyphicon glyphicon-minus ]"></span>
                </label>
                <label for="fancy-checkbox-info-custom-icons" class="[ btn btn-default active ]">
                    History
                </label>
            </div>
        </div>
</div>

In my views I'm tryign to get which checkboxes are on like this:

def random_trip(request):
    keyword = request.POST.get('keyword')
    checks = request.POST.getlist("checkbox-success-custom-icons"
    .....

However, all I get is empty list. Where is the problem?




Aucun commentaire:

Enregistrer un commentaire