From 3f31fd98f6f1474106e7b0d4cfc900e830cb0872 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Sun, 3 Nov 2024 19:45:34 +0800 Subject: [PATCH] remove thumbnail auto-removal --- README.rst | 1 - sorl/thumbnail/fields.py | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/README.rst b/README.rst index 948d19fdf..e60778624 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,6 @@ Features at a glance - Admin integration with possibility to delete - Dummy generation (placeholders) - Flexible, simple syntax, generates no html -- ImageField for model that deletes thumbnails (only compatible with django 1.2.5 or less) - CSS style cropping options - Back smart cropping, and remove borders from the images when cropping - Margin calculation for vertical positioning diff --git a/sorl/thumbnail/fields.py b/sorl/thumbnail/fields.py index 4d84e1703..b3d4e20e6 100644 --- a/sorl/thumbnail/fields.py +++ b/sorl/thumbnail/fields.py @@ -1,6 +1,5 @@ from django import forms from django.db import models -from django.db.models import Q from django.utils.translation import gettext_lazy as _ from sorl.thumbnail import default @@ -9,24 +8,6 @@ class ImageField(models.ImageField): - def delete_file(self, instance, sender, **kwargs): - """ - Adds deletion of thumbnails and key value store references to the - parent class implementation. Only called in Django < 1.2.5 - """ - file_ = getattr(instance, self.attname) - - # If no other object of this type references the file, and it's not the - # default value for future objects, delete it from the backend. - query = Q(**{self.name: file_.name}) & ~Q(pk=instance.pk) - qs = sender._default_manager.filter(query) - - if (file_ and file_.name != self.default and not qs): - default.backend.delete(file_) - elif file_: - # Otherwise, just close the file, so it doesn't tie up resources. - file_.close() - def formfield(self, **kwargs): defaults = {'form_class': ImageFormField} defaults.update(kwargs)