Actually, you need to use any background library ( like https://github.com/arteria/django-background-tasks/ ) for processing large-time operations such as image processing.
On Friday, 17 November 2017 15:24:25 UTC+2, Дмитрий Горобец wrote: > > I want to save webp image near jpg version. > > Now I'm doing it this way: > class ProductImage(models.Model): > product = models.ForeignKey( > to=Product, > related_name='images', > on_delete=models.CASCADE, > ) > > image = models.ImageField( > upload_to=upload_product_image, > default='', > blank=True, > max_length=255, > ) > > def save(self, **kwargs): > super().save(**kwargs) > self.create_webp_image() > > def create_webp_image(self): > image = Image.open(self.image.path) > path = os.path.splitext(self.image.path)[0] + '.webp' > image.save(path, 'WEBP') > > Is there more elegant way to do it? > > Thank you. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a5c78827-bc18-4857-aacc-712916c85fef%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

