How to delete old image when update ImageField?

前端 未结 8 1589
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 09:20

I\'m using Django to create a stock photo site, I have an ImageField in my model, the problem is that when the user updates the image field, the original image file isn\'t d

8条回答
  •  Happy的楠姐
    2020-12-13 09:47

    Use django-cleanup

    pip install django-cleanup
    

    settings.py

    INSTALLED_APPS = (
        ...
        'django_cleanup', # should go after your apps
    
    )
    

提交回复
热议问题