I've added filter horizontal
filter_horizontal = ('blocked_email_notifications',)
To my ModelAdmin
, but it's still rendering it as a multiple select widget, rather than the nifty javascript enhanced version. How come? Do I need to add something else?
The user model has it defined as
blocked_email_notifications = ManyToManyField('EmailTemplate', blank=True)
And the form has it defined as
blocked_email_notifications = ModelMultipleChoiceField(queryset=EmailTemplate.objects.order_by('key'), required=False)
If you define the field in the form you need to include the widget:
from django.contrib.admin.widgets import FilteredSelectMultiple
blocked_email_notifications = ModelMultipleChoiceField(
queryset=EmailTemplate.objects.order_by('key'),
required=False,
widget=FilteredSelectMultiple(
verbose_name=EmailTemplate._meta.verbose_name,
is_stacked=False))
is_stacked
:
False
: the lists are rendered side by sideTrue
: the lists are rendered one underneath the otherIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With