« REST design notes | Main | links for 2007-08-20 »

Presentation Logic and Django Templates

On Django templates: "Any designers I have worked with would be completely overwhelmed."

I can't agree. Short of providing a CMS with a fullblown editing environment (and remembering that the self-serving nature of tool support means the template language will become complicated), Django's templates are just the kind of stuff you need to give a non-programmer. They successfully split presentation boilerplate from content.

Sometimes you have logic that is presentation related and the "no code" rule means contorting and optimizing your model or your other logic for that presentation need. Presentation logic is a real requirement and it has to go somewhere. The most important architectural precept to know about presentational logic is that there is one to many relationship between it and application logic. A single web based system will often need to support multiple presentational needs. The traditional MVC on 3-tiered diagrams you see tend to miss this point entirely, as they usually only show one presentational layer and one application layer - in reality there are many presentational layers. You really don't want that stuff embedded in your domain.

A good templating design means you have the minimum amount of distraction and irrelevance when it comes to adding new content, but in a way where presentational issues are not pushed backed into the code. Django templates provide enough control structures to display content - expressive enough for presentations but not for models or business programming. This approach to explicitly limit a language is called Least Power.


Originally written on 2006-05-11; still seems relevant

August 20, 2007 07:38 AM

Trackback Pings

TrackBack URL for this entry:
http://www.dehora.net/mt/mt-tb.cgi/1778