I am wondering if someone can help me figure out the best approach to the following problem. I’m building a web application which uses Django templating to construct its web UI component. There are a number of common HTML elements such as the header / footer, HTML head, masthead etc. I’d like to code these once and ‘include/combine’ them with other templates representing the core application functionality.
Is this possible using Django Templates? If so how might I go about accomplishing that?
You can use django’s
extendstag. Say you had a header and footer. You could make a template, called, say, foo.django:Then, you can make another template, say, bar.django:
…which will then render:
There’s good instructions on django templates at http://www.djangobook.com/en/1.0/chapter04/.