0

Let say I have a model which has a profile pic image field.As a user I uploaded a profile pic.When I upload a new profile pic, old profile has to get deleted. How to handle this scenario in development and production stage

Rahul
  • 21
  • 3

1 Answers1

0

Use django-cleanup, it automatically deletes unnecessary files from server.

pip install django-cleanup

And add it to your settings.py:

INSTALLED_APPS = [
    ...
    'django_cleanup'
]

Possible duplicate of: https://stackoverflow.com/a/28986357/7320045

Osman Omar
  • 433
  • 1
  • 7
  • 19