Book Image

Django 1.0 Template Development

Book Image

Django 1.0 Template Development

Overview of this book

Table of Contents (17 chapters)
Django 1.0 Template Development
Credits
About the Author
About the Reviewers
Preface
Index

Template strategy


There is no "magic number" or "correct" number of template files to have in your site. Every project's needs are different; some sites will have just a couple of templates, others may have dozens.

A good rule of thumb is that if you are repeating any part of your template on more than one or two pages, it's a good candidate to be put in its own file. This will save you time and effort down the line when you have to maintain these files by only having to make a change in one place.

With some planning, you can make your templates very flexible by creating blocks in your templates that you can use in child templates when the need arises.

Creating content placeholders

One thing you'll probably want to do in your templates is create placeholders for JavaScript and CSS that can be supplied by your child templates.

Note

When you define a block in a parent template, you are not required to use it in a child template. If you don't, the template engine will just return an empty block...