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

This commit is contained in:
Jeremy Stretch 2024-02-16 09:00:22 -05:00
parent 2e74952ac6
commit de5c5aeb2a

View File

@ -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(