Задать вопрос

Тел: +7 965 3737 888





Clear FileField/ImageField files in the Admin

The widget for FileField and ImageField has a problem: it doesn't supports clear its value and it doesn't delete the old file when you replace it for a new one.

This is a solution for this. It is just for Admin, but you can make changes to be compatible with common forms.

The jQuery code will put an <input type="checkbox"> tag next to every <input type="file"> and user can check it to clear the field value.

When a user just replace the current file for a new one, the old file will be deleted.

Вопрос полезен? Да0/Нет0

Ответы (2):

Ответ полезен? Да0/Нет0

This snippet works great for me.I was using Django1.2.5 and its a kind of facility provided in Django1.4b. I wanted this to work in admin and it worked perfectly.

Thanks marinho . Great

Ответ полезен? Да0/Нет0

How would I change this to work with regular forms?