Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Image(models.Model):
- product = models.ForeignKey(Product, related_name='images', on_delete=models.CASCADE)
- # we need this key to the original image because otherwise we can get/update individual cropped images
- parent = models.ForeignKey('self', blank=True, null=True, verbose_name='original image', on_delete=models.CASCADE)
- image = models.ImageField(upload_to=file_upload_to)
- image_type = models.CharField(max_length=50)
- if crop_image(disk_path, new_disk_path, size):
- Image.objects.update_or_create(image_type=type_key, parent_id=parent_id, product_id=product_id,
- defaults={'image': new_db_path})
Add Comment
Please, Sign In to add comment