Skip to content

Sicilia04/django-checkboxselectmultiple

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-checkboxselectmultiple

Django widget for using multiple checkboxes instead <select multiple>.

The benefit of using this instead of Django's default is better integration with Django Admin.

Javascript is based on Stefano Contini's code http://www.abidibo.net/blog/2013/04/10/convert-select-multiple-widget-checkboxes-django-admin-form/

Installation

You can install django-checkboxselectmultiple with pip

pip install https://github.com/MagicSolutions/django-checkboxselectmultiple/archive/master.zip

And put it INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'checkboxselectmultiple',
    ...
)

Usage

You can set the widget to your form fields

from django import forms
from checkboxselectmultiple.widgets import CheckboxSelectMultiple

class MyForm(forms.Form):

    choice_fields = forms.MultipleChoiceField(
        choices=MY_CHOICES, widget=CheckboxSelectMultiple)

    model_choice_fields = forms.ModelMultipleChoiceField(
        queryset=queryset, widget=CheckboxSelectMultiple)


class MyModelForm(forms.ModelForm):

    class Meta:
        model = MyModel
        widgets = {
            'my_fields': CheckboxSelectMultiple,
        }

Integrating with django administration

from checkboxselectmultiple.admin import CheckboxSelectMultipleAdmin

class MyAdmin(CheckboxSelectMultipleAdmin):
    pass

admin.site.regiter(MyModel, MyAdmin)

About

Django widget for using multiple checboxes instead of <select multiple>

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 50.4%
  • Python 39.8%
  • CSS 9.8%