From c660f1c019ddb46713f830c360dd5804784c73df Mon Sep 17 00:00:00 2001 From: Jason Novinger Date: Mon, 16 Jun 2025 09:54:11 -0400 Subject: [PATCH] Fixes #19702: add NotificationGroup.event_rules GenericRelation The collector we use to notify users about dependent object that will be deleted does handle GFKs. However, a GenericRelation must be set up on the other end. --- netbox/extras/models/notifications.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/netbox/extras/models/notifications.py b/netbox/extras/models/notifications.py index 7fe03147c..44874a4c8 100644 --- a/netbox/extras/models/notifications.py +++ b/netbox/extras/models/notifications.py @@ -1,7 +1,7 @@ from functools import cached_property from django.conf import settings -from django.contrib.contenttypes.fields import GenericForeignKey +from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.core.exceptions import ValidationError from django.db import models from django.urls import reverse @@ -144,6 +144,12 @@ class NotificationGroup(ChangeLoggedModel): blank=True, related_name='notification_groups' ) + event_rules = GenericRelation( + to='extras.EventRule', + content_type_field='action_object_type', + object_id_field='action_object_id', + related_query_name='+' + ) objects = RestrictedQuerySet.as_manager()