I have recently added new ImageField to my Bird model in Django application.
# models.py
class Bird(models.Model):
name = models.CharField(max_length=50)
project = models.ForeignKey(
Project,
related_name='birds',
on_delete=models.CASCADE
)
def bird_images_path(instance, filename):
return 'bird_images/' + instance.project.directory + '/' + filename
image = models.ImageField(upload_to=bird_images_path, null=True, blank=True)
In django admin I have added new records to Bird table in db, uploaded images and they appered in my media path (\media\bird_images\birds) as expected. Everything worked well.
Nevertheless, after some time some weirdly named copies of my previous files appeared in the same location. For example, dove_ee9rsOT.jpg and dove_zRCwQrj.jpg are now saved next to originally uploaded dove.jpg. All three images are identical and the database record contains one of the new ones.
However, I don't recall adding any such images and nobody else has access to my app. Is there any explanation for this behavior or a way how to prevent it?