1

I have two fields in my django model:

 class Staff(models.Model):

    photo = models.FileField(blank=True, null = True)
    encodings = JSONField()

I get the photo from form and after that using this photo get encodings. How can I delete the photo after proccesing it? I tried

self.photo = None or self.photo = ''

but in this case I get "The 'photo' attribute has no file associated with it"

yaschk
  • 320
  • 1
  • 11

1 Answers1

0

You can import the os module and then do:

os.remove(path/to/photo)

Also, if you are only processing photos, you should use ImageField instead of FileField in my opinion.

Daniel
  • 131
  • 1
  • 9