On 10/20/05, kmh <[EMAIL PROTECTED]> wrote: > Seeing it in writing got me wondering though if the whole idea of > application templates "extending" the base site is wrong-headed. > Because the application knows nothing about the site it is to be > embedded in, the application writer is second-guessing what base > template it is supposed to extend. Say the 'blog' and 'gallery' > applications need to appear on the same page in different > columns...what then?
The way we've done things for the past 2 years at World Online, with dozens of decoupled Django apps, is to have a standard convention for templates. Here's a short explanation of the convention, which I think we should promote: * All app templates assume there's a "base_generic" template and {% extend %} it. * All app templates assume the <title> is in {% title %}. * All app templates assume there's a {% block extrahead %} within the <head>. This is a hook for putting arbitrary things in <head>. * All app templates assume the parent templates have defined {% block content %}, for the main content area of the page. Essentially, the convention is to assume these base templates: base.html: """ <html> <head> <title>{% block title %}{% endblock %}</title> {% block extrahead %}{% endblock %} </head> <body> {% block content %}{% endblock %} </body> </html> """ base_generic.html """ {% extends "base" %} <!--Provides a hook for customizing the look and feel on a "section"-specific basis. For example, this can customize subnavs. Make a base_* template for each section of the site, e.g. base_sports, base_news, base_about. --> """ Solidifying a convention like this would go a long way in making Django apps easily pluggable (via their default templates). Of course, it shouldn't (and won't) be required that app users *use* the default templates that come with an app -- they're just a quick starting point and serve as documentation. I'd even go so far as to say we could include the above base.html and base_generic.html in the Django distribution proper, to give people a starting point when creating their templates. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org