I am working with a multi-site wagtail project. And I want an event class which contains ParentalManyToManyField field called sites. The idea is that each event will be associated with multiple sites not necessarily all.
Two sites X and Y have lots of events and most of them are common. So I want to make default checkbox selected for two of the sites while resting unchecked in event content_panels.
My event class is as follows.
from django import forms
from wagtail.core.models import Orderable, Page, Site
from modelcluster.fields import ParentalKey, ParentalManyToManyField
class Event(Page):
....
sites = ParentalManyToManyField(Site)
...
Event.content_panels = [
...
FieldPanel('sites', widget=forms.CheckboxSelectMultiple),
...
]
I found following code somewhere and tried it but it makes all options checked.
Event.content_panels = [
...
FieldPanel('sites', widget=forms.CheckboxSelectMultiple(attrs={"checked":""}))
I want just two specific options to be checked and rest unchecked by default.