I've been trying to make a template layout for Django that makes sense, something similar to existing PHP frameworks, where the head section is in one file, and the body is in another.

To do that I simply created a file called head.html (under templates/ obviously), and included it:

head.html

1
2
<script type="text/javascript" src= "jQuery.js"></script>
<title>My website </title>

Now using the Django templating language, we simply include the file:

index.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!DOCTYPE html>
&lt;html&gt;  </p>
<p>	&lt;head&gt;
		%7B%25 include &quot;head.html&quot; %25%7D
	&lt;/head&gt;
	&lt;body&gt;
		%7B%25 block content %25%7D
		&lt;h1&gt;Default Header&lt;/h1&gt;</p>
<p>		&lt;div&gt;
			Default Content
		&lt;/div&gt;
		%7B%25 endblock %25%7D
	&lt;/body&gt;
&lt;/html&gt;

This seems fine for starters, but what if we want to change the content (outrageous isn't it)?

In this case, we could use extend (on that specific page), which is a very powerful tool to get some generic layouts and always have the ability to override them, in this case we just override the content by redeclaring the block:

special_page.html

1
2
3
4
5
6
7
8
9
10
%7B%25 extends &quot;index.html&quot; %25%7D
%7B%25 block content %25%7D
	&lt;h1&gt;Special Header&lt;/h1&gt;
	&lt;ul&gt;
		&lt;li&gt;First&lt;/li&gt;
		&lt;li&gt;Second&lt;/li&gt;
		&lt;li&gt;Third&lt;/li&gt;
		&lt;li&gt;Fourth&lt;/li&gt;
	&lt;/ul&gt;
%7B%25 endblock %25%7D

There are different ways for creating these layouts on Django, though not many examples are given (at least not without digging in github).

If we want to build a website with a lot of pages, most of them none-static (stored on the Database, Flatpages is a very helpful package (application?) for that.
It allows you to store pages on the database, and have a default layout for them (which you can customize).

Another helpful package along that line would be Django-chunks which works just like blocks for those of you familiar with popular CMS's

I've noticed that the best approach (for me at least) is to implement layouts on my own,
That way, I have to learn more about a core feature (templating and rendering) of Django instead of learning some third party package,
not to mention nothing is more familiar than your own code (hopefully).

Update
I highly recommend using django-apptemplates,
it's very helpful when extending and including template names that are the same throughout different applications.
To implement it you have to add the library to the TEMPLATE_LOADERS in the settings file,
and then you simply write %7B%25 extends "appname:index.html" %25%7D (adding the appname), same goes for include.