Trying To Understand Django sorl-thumbnail

I played with sorl-thumbnail for Django. And trying to figure out how it works better.

I read the manual for it, installed it in my site packages, made sure that PIL is installed correctly, put sorl.thumbnail in INSTALLED APPS in my settings.py , put from sorl.thumbnail.fields import ImageWithThumbnailsField at the top in my models.py , added image = ImageWithThumbnailsField(upload to="images/", thumbnail={'size':(80, 80)}) as one of my model fields, passed the model through my view to the template and in the added template {% load thumbnail %} at the top and add the {{ mymodel.image.thumbnail_tag }} variable there.

But from what I understood, is that when I upload an image through the administrator, it will immediately create a thumbnail, but in fact it is created only when I see my template in the browser? It's right? The thumbnail shows that it actually looks great, but I thought that adding part of the model field could create a sketch right after loading the image? ... Why not just use models.ImageField in my model?

... or did I do it all OK, and I just made it work incorrectly?

+6
python django image-processing
source share
2 answers

I am one of the developers of software thumbnails.

First, you don’t need {% load thumbnail %} unless you just use the thumbnail and not the thumbnail box.

Currently, a thumbnail is created only the first time it is used - even if you use this field [I will manage to change it one fine day if no one else does it]. The advantage of the field is that you can specify the size, rather than give freedom to the designer at the template level [and make it easier for the administrator thumbnail].

Both methods work, you decide which one is best for you.

+2
source share

how about adding jCrop to admin to specify the thumbnail area? Woul will be pretty cool :)

0
source share

All Articles