Online Library TheLib.net » Django 1.0 Template Development
cover of the book Django 1.0 Template Development

Ebook: Django 1.0 Template Development

Author: Scott Newman

00
27.01.2024
0
0
Django 1.0 Template Development by Scott Newman teaches development practices for the Django Web framework template system. The book brands itself as "a practical guide to Django template development with custom tags, filters, multiple templates, (and) caching," and is published by Packt Publishing.

I found the book to be a solid but also technical reference, especially on views, URL configuration, and pagination, making it more appropriate for the book's intended audience of "Web developers and template authors." I'm familiar with Django template development during my work as an Interaction Designer where Django was created at the Lawrence Journal-World newspaper in Lawrence, Kan.

The book assumes the reader completed the installation of Django and the introductory tutorials, in particular creating a project, an application, and some models, and development using at least Django 1.0. The book also assumes some basic knowledge of HTML, Python, and a Unix-like environment. I recommend learning essentials, such as the set up of basic Unix-like environments and how they use Python via the Python Path, before reading this book.

Chapter 1's "An Introduction to the Django Template System" is a good overview and philosophy of the template system. Chapter 2's "Views, URLs, and Generic Views" and Chapter 3's "Template Context" cover the technical background in how Django renders templates and was mainly written for Web developers. Chapter 4's "Using the Built-In Tags and Filters" contains examples of almost every tag and filter Django gives for free, which is very welcome because not even Django's official documentation has such a reference!

Chapter 5's "Loading and Inheriting Templates" starts real-world template examples, but recommends storing templates in "projects/(project name)/templates/" as a best practice, which I found to be questionable: The most common template storage practices I have seen are "(project name)/(application name)/templates/" or a dedicated directory; the former is especially common in redistributable Django applications on Google Code and GitHub.

Chapter 6's "Serving Multiple Templates" covers the juicier parts of the book: printer-friendly pages, site themes, and mobile versions (courtesy of my former co-worker Matt CroydonHi, Matt!). The printer-friendly pages were solid, although the mobile solution falls just short of perfection by not using cookies. I found site themesmanually adding and remove template directoriesnot to be a practical solution.

Chapters 7 through 11 have corresponding online documentation topics: custom tags and filters, pagination, customizing the admin, caching, and internationalization. The chapter on pagination curiously failed to mention the django-pagination application, but the chapter on caching elegantly addresses a confusing topic.

The book shows many helpful screenshots, but I would have liked more than its three information graphics, which reiterated the text preceding it; however I did find the text to be generally free of technical errors.

The book should have answered some of the more basic questions I had when first learning templates:

- Why do templates end in the .html extension rather than some kind of Django template extension, such as ".django-html"? Answer: The
- Django creators wanted your current text editor to continue highlighting HTML elements. If you come from PHP, this is definitely noteworthy.
- What is a template variable's syntax? Answer: {{ model.field }}. The book rarely mentions models.
- Is there a diverse template strategy I should use? Answer: It depends, possibly with design layouts.

The book oddly chose to author a press release application and not the most-desired blog application, covering only simple, list-, and detail-based generic viewsnot date-based generic views, which would have been desirable, but best practices, such as empty blocks for extra CSS and JavaScript in the base template, are covered.

Acknowledgment of the Django universe's free and open applications on the Internet could have given designers and front-end developers the edge in making their templates shine, such as:

- typogrify: Tags and filters in prettifying your text
- django-template-utils: Commonly used template enhancements beyond djbuilt-in tags and filters
- django-robots: Easy creation of robots.txt for search engines
- django-oembed: Auto-detection of media-esque URLs and their no-fuss replacement
- flatpages: Acknowledgment of the most basic built-in Django application showing template basics

These documentation topics and Django Book chapters roughly correspond to many of the chapters in Django 1.0 Template Development:

- The Django template language
- Built-in template tags and filters
- The Django template language: For Python programmers
- Custom template tags and filters
- Django Book, Chapter 4: Templates
- Django Book, Chapter 9: Advanced Templates

Ultimately, buying Django 1.0 Template Development comes down to what kind of learner you are: Django's official documentation, the Django Book, and the Django users Google Group, should give most Web developers and template authors enough to learn most of the template system, but the book can be a handy reference and walk-through that will hold your hand in a lot of sticky points. The examples in the book are bound to teach something to even the most seasoned Django developers.
Download the book Django 1.0 Template Development for free or read online
Read Download
Continue reading on any device:
QR code
Last viewed books
Related books
Comments (0)
reload, if the code cannot be seen