Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

image doesn't upload at resize_image field given path. #725

Open
GaziAshiq opened this issue Feb 28, 2023 · 0 comments
Open

image doesn't upload at resize_image field given path. #725

GaziAshiq opened this issue Feb 28, 2023 · 0 comments

Comments

@GaziAshiq
Copy link

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

image

@GaziAshiq GaziAshiq changed the title image dosent upload at resize_image field given path. image doesn't upload at resize_image field given path. Feb 28, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant