Guest User

Untitled

a guest
Jan 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. class Image(models.Model):
  2. product = models.ForeignKey(Product, related_name='images', on_delete=models.CASCADE)
  3. # we need this key to the original image because otherwise we can get/update individual cropped images
  4. parent = models.ForeignKey('self', blank=True, null=True, verbose_name='original image', on_delete=models.CASCADE)
  5. image = models.ImageField(upload_to=file_upload_to)
  6. image_type = models.CharField(max_length=50)
  7.  
  8. if crop_image(disk_path, new_disk_path, size):
  9. Image.objects.update_or_create(image_type=type_key, parent_id=parent_id, product_id=product_id,
  10. defaults={'image': new_db_path})
Add Comment
Please, Sign In to add comment