Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove thumbnail auto-removal #777

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions sorl/thumbnail/fields.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
Loading