17

Sep

Filed in Django |

The author of Jinja, an alternative solution to Django templates, made a great post about what is wrong with the Django template engine. It’s a great read if you have any doubts that the philosophy behind Django’s template engine makes sense.

The truest quote of them all:

I like the custom tag system in Django, and I wouln’t want to see it go away if the template engine is improved. But for example “ifnotequal foo bar” “endifnotequal” is no way better than “if foo != bar” “endif”.

6 Responses to "What’s Wrong With Django Templates"

Subscribe to this topic with RSS or get the Trackback URL
israel (Sep 17th):

I agree, the ifnotequal stuff confused me at first when i started off with Django templates. i mean, if is a standard across many languages and i think is needed in a templating system.

MockSoul (Sep 21st):

We philosophy behind “ifnotequal” and similar confusing things - they are designed not for developers, but for html authors (which may or may not know python/other language at all).

As an example: my sister clearly understands “ifnoequal A B means A not equal B” and do not understands “A != B” at all :).

Thus, django template engine actually 100% fits the idiom “template should be as easy as possible”. But not that much usable to make very complex template logic. Jinja also dont. Even plain “print’s” in python does not fit that (: And there is no product on the market which can be used to make very-very-very high performance web sites. Template engine implemented in C should be faster than plain python itself, isnt it?

We (IPI Tech) want to make that thing in MIT license (of course! :)). Currently it is in “think-think-think!” stage, so any comments are welcome. Especially from you, David (:. (jett in launchpad).

MockSoul (Sep 21st):

“We”=”The” in the first sentence. Auch!

David (Sep 21st):

You are correct in some of the assumptions MockSoul. On the other hand, most designers, or frontend developers, have to learn CSS and typically JavaScript as well. They usually understand != as it’s the most common representation in the web world.

As for performance, Jinja can be used on a high traffic website just as well as something like Smarty can. Parts of it are written in C to speed up execution of things, and it also compiles templates down to python modules/bytecode (you’d have to harass the Pocoo guys for more information on how all this works, I’m unfamiliar).

Vadim Fint (Sep 21st):

Yes, David, I know jinja internal structure a lot. I’m also know Pocoo is a very great development team. Jinja is working just like smarty (php) or mako templates (python). But that is not enougth.. :)

Words cant change the world, so.. just take a look into “jett” project at launchpad in next 3-4 months.. ;) I’m not promising it will support all jinja/django features. Also that possibly will not be extendable in such easy way as python template engines… but.. it will be FAST.

Vadim Fint (Sep 21st):

Btw, js in html or heavy css - is “complex templates” in django terms.. :). I have no idea how somebody without js/css knowledge can make complex web site.

But, again, django template engine is designed for _simplier_ websites. Maybe without js at all. Thus, person who may edit such easiest templates may NOT know about “!=”.

Note that I personally dont like django template philosophy at all.

Leave A Reply

 Username (*required)

 Email Address (*private)

 Website (*optional)

Note: Comments moderation may be active so there is no need to resubmit your comment.