Answers for "delete a file with django"

0

image delete in django from the folder

class Song(models.Model):
    name = models.CharField(blank=True, max_length=100)
    author = models.ForeignKey(User, to_field='id', related_name="id_user2")
    song = models.FileField(upload_to='/songs/')
    image = models.ImageField(upload_to='/pictures/', blank=True)
    date_upload = models.DateField(auto_now_add=True)

    def delete(self, using=None, keep_parents=False):
        self.song.storage.delete(self.song.name)
        self.image.storage.delete(self.song.name)
        super().delete()
Posted by: Guest on October-06-2020
0

delete file in django terminal

rm -r projectfoldername
Posted by: Guest on December-07-2020

Python Answers by Framework

Browse Popular Code Answers by Language