diff --git a/openwisp_monitoring/device/api/views.py b/openwisp_monitoring/device/api/views.py index a97cae9f..97841c00 100644 --- a/openwisp_monitoring/device/api/views.py +++ b/openwisp_monitoring/device/api/views.py @@ -114,6 +114,7 @@ class DeviceMetricView( queryset = ( DeviceData.objects.filter(organization__is_active=True) .only( + '_is_deactivated', 'id', 'key', ) diff --git a/openwisp_monitoring/device/apps.py b/openwisp_monitoring/device/apps.py index 4cbbd347..3690c643 100644 --- a/openwisp_monitoring/device/apps.py +++ b/openwisp_monitoring/device/apps.py @@ -155,6 +155,11 @@ def connect_device_signals(self): sender=Device, dispatch_uid='device_deactivated_update_devicemonitoring', ) + device_deactivated.connect( + DeviceMetricView.invalidate_get_device_cache, + sender=Device, + dispatch_uid=('device_deactivated_invalidate_view_device_cache'), + ) @classmethod def device_post_save_receiver(cls, instance, created, **kwargs):