Skip to content

Commit

Permalink
skip updating existing attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
knifecake committed Dec 22, 2024
1 parent c5d8c48 commit a8bafe5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions anchor/models/fields/single_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ def __get__(self, *args, **kwargs) -> Attachment | None:

def __set__(self, instance, value):
if isinstance(value, Attachment):
value.object_id = instance.id
value.content_type = ContentType.objects.get_for_model(instance)
value.name = self.name
value.order = 0
value.save()
if value._state.adding:
value.object_id = instance.id
value.content_type = ContentType.objects.get_for_model(instance)
value.name = self.name
value.order = 0
value.save()

return

if isinstance(value, Blob):
Expand Down

0 comments on commit a8bafe5

Please sign in to comment.