Django - Uploaded image gets saved twice: under original and validated name
You are calling save twice one with super and other with save to fix it do this:
from io import BytesIO
from django.core.files.uploadedfile import InMemoryUploadedFile
import sys
class SparePartImages(models.Model):
# rest of the code
def save(self, *args, **kwargs):
# rest of the code
# but remove file.save(removeAccent(self.image.path))
output = BytesIO()
file.save(output, format='JPEG', quality=100)
output.seek(0)
self.image = InMemoryUploadedFile(
output ,'ImageField', "%s.jpg" %self.image.name.split('.')[0], 'image/jpeg', sys.getsizeof(output), None
)
super(SparePartImages, self).save(*args, **kwargs)