Roberto Aguilar wrote:
In my situation, what I wanted to do was limit the display of a bunch
of menu items depending on the group of the user. I accomplished this
with a for loop and a test for a group:
{% for group in user.get_list %}
{% ifequal group 'desired_group' %}
[...]
It's a two-step process rather than one, but it gets the job done.
That being said, should the menu evaluation go in a view rather than
the template? To me it sounds logical to keep the menu in the
template, but what do the more experienced django developers have to
say?
It depends on the circumstance, as most things do. For simple cases it
might suffice in your template code. However, if you are doing a lot of
logic there and you start to see more {% ... %} than HTML tags, then
that is probably the point when you want to build a {% site_menu %}
custom tag.
That's the key, really. It is it "too much" logic, and that is in some
way an aesthetic judgment.
--
--Max Battcher--
http://www.worldmaker.net/