Is there a reason why I should be discouraged from using an alternative template in my Django application?

I did some small Django projects, and every time I was struck by the obvious limitations of the Django template language. Just like a random example, I was shocked to learn that if in the context of the template I had a variable panel and dict foo, I would not be able to access foo [bar] if I had not written my own filter for this.

I read that the reason for this is that Django was created for environments where the people who designed the pages were not programmers. I understand it.

But say this is not a problem for me. Is there a reason why I should stick with the Django template language instead of switching to something with much greater power like Mako (where you can even execute arbitrary Python expressions)?

I had the opportunity to use Mako for a school project some time ago, and I really loved his strength. For example, in the framework of the project, we had to compile a large table, where the construction of each row and cell was quite complicated. However, I could make my template look something like this:

<table>
    % for foo in foos:
        ${makerow(row)}
    % endfor
</table>

<%def name="makerow(row)">
    <tr>
        # Blah blah blah (possibly a call to makecell somewhere)
    </tr>
</%def>

Perhaps this is a violation of the separation of representation and logic, but the boy is good and pure. Routines! Abstraction! Good material.

: Django, - ? , , , , Django.

+3
6

, . , " python " " ".

, , - . ( , ) 3 . - .

, , , . Django, . , Mako Jinja - .

Django -: http://docs.djangoproject.com/en/dev/ref/templates/api/#using-an-alternative-template-language

+4

. .

, Django, , , , . Django , - ORM.

Mako Django, Mako.

+2

, jinja, Mako , , django.

GSoc, , . - NoSQL.

django, , .

python, , , Flask .

+2

addons.mozilla.org Django + Jinga: https://github.com/jbalogh/zamboni

, Jinga, .

+1

"", "", , ; - - , , .

0

PHP, PHP html . . , .

"", ? , , .

0

Source: https://habr.com/ru/post/1776145/


All Articles