Просмотр исходного кода

Fixes #14952: Update existing AutoSyncRecord when changing the data file of an auto-synced object

Jeremy Stretch 2 лет назад
Родитель
Сommit
de5c5aeb2a
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      netbox/netbox/models/features.py

+ 3 - 3
netbox/netbox/models/features.py

@@ -489,10 +489,10 @@ class SyncedDataMixin(models.Model):
         # Create/delete AutoSyncRecord as needed
         content_type = ContentType.objects.get_for_model(self)
         if self.auto_sync_enabled:
-            AutoSyncRecord.objects.get_or_create(
-                datafile=self.data_file,
+            AutoSyncRecord.objects.update_or_create(
                 object_type=content_type,
-                object_id=self.pk
+                object_id=self.pk,
+                defaults={'datafile': self.data_file}
             )
         else:
             AutoSyncRecord.objects.filter(