-
-
Notifications
You must be signed in to change notification settings - Fork 498
Description
from sorl.thumbnail import ImageField, get_thumbnail
from django.db import models
class Product(models.Model):
image = ImageField(upload_to='products/images/', help_text='main image of the product')
resized_image = ImageField(upload_to='products/images/resized/', editable=False)
def save(self, *args, **kwargs):
super(Product, self).save(*args, **kwargs)
if self.image:
self.resized_image = get_thumbnail(self.image.path, '500x500', quality=99, format='JPEG').url
super(Product, self).save(*args, **kwargs)
here is my code. The problem is, when I upload image, thumbnail generate at 'media/cache' folder rather then 'product resize' folder
[28/Feb/2023 12:40:19] "GET /media/products/images/IMG_4555.JPG HTTP/1.1" 304 0
[28/Feb/2023 12:40:31] "GET /media/media/cache/7b/aa/7baabac17061d630d9f31adfcc7a2250.jpg HTTP/1.1" 404 3065 [28/Feb/2023 12:40:39] "GET /media/cache/7b/aa/7baabac17061d630d9f31adfcc7a2250.jpg HTTP/1.1" 304 0