File tree Expand file tree Collapse file tree 2 files changed +0
-20
lines changed
Expand file tree Collapse file tree 2 files changed +0
-20
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ Features at a glance
1313- Admin integration with possibility to delete
1414- Dummy generation (placeholders)
1515- Flexible, simple syntax, generates no html
16- - ImageField for model that deletes thumbnails (only compatible with django 1.2.5 or less)
1716- CSS style cropping options
1817- Back smart cropping, and remove borders from the images when cropping
1918- Margin calculation for vertical positioning
Original file line number Diff line number Diff line change 11from django import forms
22from django .db import models
3- from django .db .models import Q
43from django .utils .translation import gettext_lazy as _
54
65from sorl .thumbnail import default
98
109
1110class ImageField (models .ImageField ):
12- def delete_file (self , instance , sender , ** kwargs ):
13- """
14- Adds deletion of thumbnails and key value store references to the
15- parent class implementation. Only called in Django < 1.2.5
16- """
17- file_ = getattr (instance , self .attname )
18-
19- # If no other object of this type references the file, and it's not the
20- # default value for future objects, delete it from the backend.
21- query = Q (** {self .name : file_ .name }) & ~ Q (pk = instance .pk )
22- qs = sender ._default_manager .filter (query )
23-
24- if (file_ and file_ .name != self .default and not qs ):
25- default .backend .delete (file_ )
26- elif file_ :
27- # Otherwise, just close the file, so it doesn't tie up resources.
28- file_ .close ()
29-
3011 def formfield (self , ** kwargs ):
3112 defaults = {'form_class' : ImageFormField }
3213 defaults .update (kwargs )
You can’t perform that action at this time.
0 commit comments