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