Answers for "django trigger when an instance od data is deleted from model"

0

django trigger when an instance od data is deleted from model

class ImageQuerySet(models.QuerySet):

    def delete(self, *args, **kwargs):
        for obj in self:
            obj.img.delete()
        super(ImageQuerySet, self).delete(*args, **kwargs)

class Image(models.Model):
    objects = ImageQuerySet.as_manager()
    img = models.ImageField(upload_to=get_image_path)
    ...
    def delete(self, *args, **kwargs):
        self.img.delete()
        super(Image, self).delete(*args, **kwargs)
Posted by: Guest on June-17-2021

Code answers related to "django trigger when an instance od data is deleted from model"

Python Answers by Framework

Browse Popular Code Answers by Language