2022-04-03
Overwrite image in Django
Part of workflow of my side project "Side Project List" (shut down) is:
- Add data manually on local Django app: site url, twitter handle, full name, etc
- Selenium saves screenshot to local file
e.g. /media/screenshot/name1
- Upload to Cloudinary
- ...
Issue:
Noted same screenshots were saved locally with different names overtime e.g. name1, name1_abc, name1_xyz, etc
Solution:
Make Django overwrite — actually remove and save — instead of saving with new random name