image delete in django from the folder

Solutions on MaxInterview for image delete in django from the folder by the best coders in the world

showing results for - "image delete in django from the folder"
Annabeth
23 Mar 2018
1class Song(models.Model):
2    name = models.CharField(blank=True, max_length=100)
3    author = models.ForeignKey(User, to_field='id', related_name="id_user2")
4    song = models.FileField(upload_to='/songs/')
5    image = models.ImageField(upload_to='/pictures/', blank=True)
6    date_upload = models.DateField(auto_now_add=True)
7
8    def delete(self, using=None, keep_parents=False):
9        self.song.storage.delete(self.song.name)
10        self.image.storage.delete(self.song.name)
11        super().delete()
12