Reputation: 3222
I have a ModelMultipleChoiceFilter working, however I cant find a way to adjust it from a input multiple choice to a checkbox list.
This is what I currently have:
This is what I want to convert it to:
My current code:
class GameFilter(django_filters.FilterSet):
gamemodes = django_filters.ModelMultipleChoiceFilter(
queryset=GameMode.objects.all(),
label='Game modes (or)',
)
Upvotes: 2
Views: 965
Reputation: 21787
Simply pass the keyword argument widget
with CheckboxSelectMultiple
[Django docs] to your filter:
from django import forms
class GameFilter(django_filters.FilterSet):
gamemodes = django_filters.ModelMultipleChoiceFilter(
queryset=GameMode.objects.all(),
label='Game modes (or)',
widget=forms.CheckboxSelectMultiple,
)
Upvotes: 4