Monday, March 20, 2017

Re: drop down multi checkbox with bootstraps selet

thank you for your help

بتاريخ السبت، 18 مارس، 2017 6:58:07 م UTC+2، كتب ايهاب توفيق:

I am tring to create drop down checkbox with values from database   in my templet using bootstrap select and form MultipleChoiceField like this

 

Html

select class="selectpicker" multiple>

    {% for topping in form.the_topping %}

    <option value="{{ topping }}">{{ topping.topping_id }}</option>

 

    {% endfor %}

</select>

 

<script type="text/javascript">

$(document).ready(function() {

      $('.selectpicker').selectpicker({

    style: 'btn-info',

    size: 4

        });

                                });

</script>

Form.py

class ProfileForm(forms.ModelForm):
    the_topping = forms.ModelMultipleChoiceField(
queryset=Topping.objects.all(), required=False, widget=forms.CheckboxSelectMultiple)

   
class Meta:
        model = Pizza
        exclude = [
'user']

 

the bootstrp working and the form is working but doesnot combined

 

can any one help me PLS

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ef81db93-c69b-427c-bd0e-c69ec75bd9a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment