If you have ever looked for a book on the subject of Django templates, then a five minute search on the web will soon tell you that they are far and few between. In fact, you’ll most likely find that Django templating usually has a treatment taking up no more than a couple of chapters in an otherwise lightly related book.
Django 1.0 Template Development is virtually one of a kind on its subject matter and, therefore, necessarily covers the subject in sufficient breadth and depth. On that strength alone, the book should probably hold its place on any template author or web developer’s bookshelf for some time to come.
The book purports to have its audience as web developers and template authors looking to leverage all the qualities provided by such a complete templating system as Django (version 1.0). It also assumes that the reader has completed some of the introductory tutorials on the Django project web site, as well as having a basic level of Python and HTML experience.
The book is built, as indeed are most, around a small set of sample applications that grows as the book progresses through the chapters. It starts with an introduction to the template system, covering the many advantages of using templates, such as modularity, flexibility and accessible syntax. It also mentions some limitations, which are covered in more detail later in the book, and what some of Django’s critics have to say. The next couple of chapters breeze through how views are set up, how URLs are configured, what generic templates are, and finally the uses of context data.
Chapter 4 is curious in that it is a selected skim through the online Django documentation page on built-in template tags and filters: one would normally expect to find this in an appendix. Interestingly, on some of the entries it reduces considerably what is written in the online documentation. Conversely, the treatment of other entries is more verbose. There’s no doubt that having a reference to hand on paper like this is a bonus – I found myself looking to it time and time again. On the other hand, some may come back to the old programmer’s adage – ‘you can’t grep dead trees’.
Chapter 5 jumps back into the sample applications with a reasonably in-depth look at Django’s take on template loading and inheritance. Chapter 6 sets the book apart from many other web development books I have read over the years, in the way that it considers a web application to be accessible from a variety of web browsing platforms, not just a pc and a browser. It takes a look at different approaches to using Django to serve multiple templates for different platforms, including mobile devices and how to create site themes.
Continuing with the ever growing set of sample applications, Chapter 7 takes the reader into the very interesting, but potentially complex, subject area of custom tags and filters. If there is a case for having a reasonable amount of Python knowledge to hand before starting, then it is in this chapter where it becomes evident.
Every web developer’s bread and butter, pagination, is the main subject of Chapter 8. Typically, Django undertakes pagination effortlessly and so the book has time to cover other issues around the paging of records such as how to prevent orphaned records and looking at database performance.
Chapter 9 shows the reader how the look and feel of Django’s excellent admin interface can be changed in a few simple steps. There is no exploration of how to change functionality in the admin interface; it is made clear that there is plenty of online documentation on how to do that – indeed that would deserve a book all of its own.
Chapter 10 investigates Django’s template caching framework, why one might need to use it and different caching strategies, such as per-view caching, automatic site wide caching and working with other cache systems. Chapter 11 is a brief look at another of Django’s strengths, internationalisation. At this point the reader starts one last sample application and completes some basic exercises to enable a site to speak in English and German.
Without taking anything else away from the rest of the book, the highlight chapter for me has to be Chapter 3 with an in-depth exploration of the context rendering shortcuts. It is at that point where one experiences the joy of revisiting code written in previous chapters, chopping sections of code out and replacing them with more succinct, yet more functional lines.
The chapters are well laid out, each starting with a list of expected outcomes and finishing with a summary of what one should have understood by the end. The subjects in each chapter are, in general, well explained and the code examples are sufficiently set out to support the points made by the author. Good use is made of the Django shell to explain more complex ideas, where template examples on their own would not be enough, particularly in the chapter dealing with pagination.
As stated at the start, the book makes clear its intended audience. I would add that to fully understand some of the ideas discussed, particularly in Chapter 7, one really does need a reasonable grip on the Python language – especially function structure and exceptions. I also feel that it would have been advantageous to have a little more in depth coverage of URL configuration in the earlier stages of the book. Again on the subject of internationalisation it is probably a little light, but understandably so, for the sake of brevity.
However when one considers the breadth of such a subject and the audience it tries, and largely succeeds, to appeal to, one would have to describe the book as a success. It covers a wide range of subjects in an easy going, enjoyable and friendly manner to a sufficient degree, for it to be an excellent addition to anyone’s list of well thumbed technical books.
The format and layout of the book is a typical example of the Packt Publishing house – the text and diagrams are clear and simple, the style and layout are pitched just about right.
I would certainly recommend this book to any template developer out there right now looking at using Django, on the strengths of its valuable, distilled and well presented content and the niche in which it sits at the moment.
Book Details
Author: Scott Newman
Title: Django 1.0 Template Development
Edition: First
Published: December 2008
Publisher: Packt Publishing, Birmingham, UK
ISBN: 1847195709
ISBN 13: 978-1-847195-70-8
Format: Paperback
Pages: 252 [191mm x 235mm]
Price: $39.99/£24.99
Resources
Packt web site page on Django 1.0 Template Development
A sample of Chapter 6 is available here
References
http://docs.djangoproject.com/en/dev/ref/templates/builtins/
No Comments on “Book Review: Django 1.0 Template Development”
You can track this conversation through its atom feed.