O'Reilly logo

Django By Example by Antonio Melé

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating image thumbnails using sorl-thumbnail

We are displaying the original image in the detail page but dimensions for different images may vary a lot. Also, the original files for some images might be huge, and loading them might take too long time. The best way to display optimized images in a uniform way is to generate thumbnails. We are going to use a Django application called sorl-thumbnail for this purpose.

Open the terminal and install sorl-thumbnail using the following command:

pip install sorl-thumbnail==12.3

Edit the settings.py file of the bookmarks project and add sorl.thumbnail to the INSTALLED_APPS settings.

Then run the following command to sync the application with your database:

python manage.py migrate

You should see an output ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required