Skip to Content
Django 3 Web Development Cookbook - Fourth Edition
book

Django 3 Web Development Cookbook - Fourth Edition

by Aidas Bendoraitis, Jake Kronika
March 2020
Intermediate to advanced
608 pages
17h 17m
English
Packt Publishing
Content preview from Django 3 Web Development Cookbook - Fourth Edition

How it works...

Responsive images are powerful and, at their base, are concerned with providing different images based on media rules that indicate the features of the displays upon which each image will be shown. The first thing we did here was to add the django-imagekit app, which makes it possible to generate the different images that are needed on the fly.

Obviously, we also will need the original image source, so in our Location model, we added an image field called picture. In the upload_to() function, we built the upload path and filename out of the current year and month, the UUID of the location, and the same file extension as the uploaded file. We also defined the image version specifications there as follows:

  • picture_desktop
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Django 2 Web Development Cookbook - Third Edition

Django 2 Web Development Cookbook - Third Edition

Jake Kronika, Aidas Bendoraitis

Publisher Resources

ISBN: 9781838987428Supplemental Content