I posted this over in the django-imagekit group before I noticed that I am 
unlikely to get any response over there due to activity level. So I am now 
over here to ask this goup.

I am using ProcessedImageField to resize images on upload in my user 
Profile model. The resizing part is working great and the resized image is 
successfully saved to my s3 bucket.

However what I would like to add is the ability to give the file a random 
name before upload. This would hopefully avoid the file name collisions 
issue. I am not sure how approach this yet, could someone point me in the 
right direction here?

I have included the code for my current model below.

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    image = ProcessedImageField(default='default.jpg', upload_to='profile_pics',
                                processors=[ResizeToFill(200, 200)],
                                format='JPEG', options={'quality': 60})

    def __str__(self):
        return f'{self.user.username} Profile'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/74120015-29cf-4232-b1ca-5b7a2ae12205n%40googlegroups.com.

Reply via email to