, delete(file) File , get_thumbnail() {% thumbnail ...%} templatetag.
, ImageFile, , (ImageFile.key) delete(), , .
, , Python File, , , Django File, Django, FileField ( ) File, .
, :
{% load thumbnail %}
{% thumbnail image "100" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}
image - models.ImageField, File:
{% load thumbnail %}
{% thumbnail image.file "100" as im %}
Python ( Storage , ):
from django.core.files.storage import FileSystemStorage
from django.core.files import File
from sorl.thumbnail import delete
class OverwriteStorage(FileSystemStorage):
def _save(self, name, content):
if self.exists(name):
img = File(open(os.path.join(self.location, name), "w"))
delete(img)
return super(OverwriteStorage, self)._save(name, content)
, sorl .