Answer the question
In order to leave comments, you need to log in
How to prevent duplication when saving images in uploads?
There is a model in Django:
class Image(models.Model):
title = models.CharField(max_length=200)
image = models.ImageField(upload_to='uploads/')
def __str__(self):
return self.title
Answer the question
In order to leave comments, you need to log in
Pass to the upload_to parameter a reference to a function that calculates the md5 hash of the file's contents and generates the appropriate name for it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question