From bfc84d2d61985d7e675d60ba818f820ffc1c9e98 Mon Sep 17 00:00:00 2001 From: Artur Borecki Date: Thu, 12 Mar 2026 13:49:45 +0100 Subject: [PATCH] fix(home/models.py): fix allowed_groups not changing in wagtail panel --- home/models.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/home/models.py b/home/models.py index f28005e..0a5ab49 100644 --- a/home/models.py +++ b/home/models.py @@ -1,8 +1,9 @@ from django.contrib.auth.models import Group -from django.db import models +from django.forms import CheckboxSelectMultiple from wagtail.admin.panels import FieldPanel from wagtail.fields import RichTextField from wagtail.models import Page +from wagtail.models.copying import ParentalManyToManyField class HomePage(Page): @@ -13,18 +14,15 @@ class HomePage(Page): class CoursePage(Page): body = RichTextField(blank=True) - allowed_groups = models.ForeignKey( + allowed_groups = ParentalManyToManyField( Group, - null=True, - blank=True, - on_delete=models.SET_NULL, related_name="course_pages", help_text="Select a group to restrict access to this course. Non-members will be prompted to purchase the course to view modules.", ) content_panels = Page.content_panels + [ FieldPanel("body"), - FieldPanel("allowed_groups", heading="Allowed Groups"), + FieldPanel("allowed_groups", widget=CheckboxSelectMultiple), ]