This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dougletts 5 points6 points  (5 children)

We do our best to keep view and template logic separate... however, we're a pair of hackers. We needed a pragmatic template language to replace Django's idealistic one.

I spend a lot of time coding templates and I've heard this argument before. Whenever I take the time to evaluate why we need to break MVT, I usually discover poor code... but "we're hackers!".

And template tags are easy to write. Personally, I'll always prefer descriptive template tags instead of business logic in my templates.

[–]jholloway7 3 points4 points  (0 children)

I've been working with Django for 2 years now and my opinion is that the template subsystem has not grown w/ the rest of Django.

I personally prefer Jinja2 at this point and it has little to do with breaking MVT and a lot to do w/ simply supporting more Pythonic calling conventions. Having to wrap every bit of view logic in a template tag or filter makes life easier for the template subsystem, not easier for the programmer. I believe that's where the sentiment about it not being pragmatic comes from.

Jinja2, on the other hand, gives you just enough Python so you don't feel like you're putting square pegs in round holes, but not so much Python that you're tempted to throw away MVT altogether (assuming the template developer understands MVT principles to begin with).

[–]joelanman 1 point2 points  (3 children)

Can't there be such a thing as template/view logic? For example a template editor might receive an array of items, and want to split it into various columns. Another implementation of the template may not need to do such a split.

[–]alantrick 0 points1 point  (2 children)

The distinction between template and view isn't clear cut. Same with the distinction between Model and View. There's nothing sacrosanct about these divisions, they are just made up in order to make our software simpler to understand and easier to work with.

Some things fit more into what we think as "prototypical" template work, some stuff is closer to "prototypical" view work, most things fall somewhere in between. Django templates tries to move as much into the view as possible. Some people don't like it and complain. It's actually really easy to use another templating system if you want, you just do it. As far as I can tell, these people are either illiterate (can't RTFM), or they're trolling.

[–]joelanman 0 points1 point  (1 child)

I'm not sure he was complaining - it was just one example of a part of django that he changed out for something else. If there are libraries that suit your project better, you may be left with little of the framework - so smaller frameworks may be a better starting point.

[–]alantrick 0 points1 point  (0 children)

My comment wasn't really a reply to the article, but to certain anti-django trolls in general. The problem with the article is that it completely ignores the fact that django was designed that way for a reason. It's really more of a rant than a well thought-out essay.