From 906e22fde1970b0b982c4b7e7c51decc982a1b38 Mon Sep 17 00:00:00 2001 From: Brian Candler Date: Tue, 30 Jan 2024 12:32:14 +0000 Subject: [PATCH] add_device_type_components.py: update the cached component counts on the Device --- scripts/add_device_type_components.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/add_device_type_components.py b/scripts/add_device_type_components.py index ccb3419..ea516b9 100644 --- a/scripts/add_device_type_components.py +++ b/scripts/add_device_type_components.py @@ -63,7 +63,9 @@ def run(self, data, commit): if items: for i in items: i.full_clean() - klass.objects.bulk_create(items) + # save() also triggers post_save_receiver for TrackingModelMixin + # which updates the counter fields on related objects + i.save() self.log_success("%s (%d): created %d %s" % (device.name, device.id, len(items),