What's New in the Third Edition of Web Development with Django Cookbook?
Tags: django, book, intermediate, advanced
Published: 2018-12-21 16:27:54

---
title: What's New in the Third Edition of Web Development with Django Cookbook?
published: true
tags: Django,Book,Intermediate,Advanced
canonical_url: http://djangotricks.blogspot.com/2018/12/whats-new-in-the-third-edition-of-web-development-with-django-cookbook.html
---

 ![](https://1.bp.blogspot.com/-1k5hzAEhLP8/XBmwNxD6hhI/AAAAAAAAB7I/Y5MGx3XPX9ksf1lEPTntMeuesixgoskewCLcBGAs/s1600/whats-new-in-the-third-edition-of-web-development-with-django-cookbook.png) 

A couple of months ago the third release of Django Cookbook was published under the title [Django 2 Web Development Cookbook - Third Edition](https://www.packtpub.com/web-development/django-2-web-development-cookbook-third-edition). This edition was thoroughly and progressively re-written by Jake Kronika, the guy who had reviewed my second edition and had added a lot of value to it. I was sure that he wouldn't disappoint the readers, so I invited him to write the update. In this article, I will guide you through the main new highlights of over 500 pages of this new book.

 
## Up to Date
 

Just like [William S. Vincent's books](https://wsvincent.com/books/), Django 2 Web Development Cookbook - Third Edition is adapted to Django 2.1 and Python 3.6. So you will be dealing with the state of the art technologies building your Django projects. Unicode strings, f-strings, `super()` without parameters, HTML5 tags, and object-oriented JavaScript to mention a few are used all over the book. The code is carefully generalized and even more adapted to the Don't-Repeat-Yourself (DRY) principle.

 
## Working with Docker
 

Docker is one of the most popular deployment technologies and Jake gives a good compact introduction how to use it with Django.

 
## Using Environment Variables for Configuration
 

[12-factor app guidelines](https://12factor.net/config) suggest saving app configuration in environment variables. In the book, there is a practical example of how to use it.

 
## Multilingual Fields even with Region-specific Language Codes
 

I introduced multilingual fields in previous editions of the book, but there they had a limitation, that region-specific languages like Australian English or Swiss German were not supported. Now they are!

 
## Using Precisely Semantic Markup with schema.org Microdata
 

Schema.org Microdata allows you to define the context of the content more specifically so that the content is more machine-readable. This was new to me and I still don't know the exact practical value of it, but I guess it is related to accessibility, new ways of presenting data via plugins, and Artificial Intelligence.

 
## Defining Custom Templates for the Default Django Form Fields
 

Since Django 1.11 form fields are rendered using templates instead of Python code and those templates can be customized. There is a recipe that shows you how to do that.

 
## Providing Responsive Images
 

HTML5 has the `<picture>` tag with `<source>` children that can be used in combination with the `sorl-thumbnail` Python package to generate different versions of the image based on your viewport size: load small image on the mobile, middle image on the tablet, and big image on the desktop or smart TV.

 
## Uploading Images and Deleting them by Ajax
 

In my previous editions, I only showed how to upload a file by Ajax and attach it to a Django model. In Jake's update, it is shown how you can also delete the image.

 
## Validating Passwords with Special Requirements
 

Since Django 1.11 you can define special requirements for the passwords of your users, for example, have a mix of small and big letters or include at least 1 number and 3 special characters, etc. There is a practical recipe how to do that.

 
## Adding Watermarks to Images
 

When it comes to branding or copyright protection, it is common to add special watermarks, semitransparent images on top of your normal pictures. Jake added an example, how to do that and it was very interesting to me.

 
## Authenticating with Auth0
 

In one recipe it is shown how to login to a Django website using Auth0, which seems to be a passwordless authentication system with integrations of popular connection services like OpenID Connect, Facebook, Google, Github, LinkedIn, PayPal, Yahoo!, and others. I haven't tried that myself yet, but it can be an interesting option for a social website.

 
## Using Redis for Caching
 

It is common to cache websites using Memcached service, but a good alternative is caching with Redis and django-redis. Moreover, you can easily save user sessions there.

 
## Creating Hierarchies with django-treebeard
 

In the previous editions, I introduced django-mptt for creating hierarchical structures. However, recently many projects are moving towards its alternative - django-treebeard which has more stability and writing speed. In the book, Jake shows you how to work with it.

 
## Conclusion
 

There was a lot of new things to learn. For example, for me personally Docker usage was new, and I haven't heard of schema.org microdata and Auth0 which were introduced in this book. All in all, I think, Jake Kronika did an enormous job with this update and it's really worth purchasing this book, especially as there is a winter-holidays sale where you can [get the EPUB, MOBI, and PDF with the code examples](https://www.packtpub.com/web-development/django-2-web-development-cookbook-third-edition) just for ~ 5 €.

 

Have a nice Christmas time and come back to this blog next year!

 
* * *
 

Cover photo by [chuttersnap](https://unsplash.com/search/photos/book-shelf).