Let's say you had a general list of things, for the sake of
simplicity, lets say 'users'. And each user had, at least, a name, so
this works:
{% for user in users %}
{{ user.name }}
{% endfor %}
Let's say you also have a variable 'the_user' that contained one of
users contained in users.
Is there a way to access the name of that user without doing something
dumb like:
{% for user in users %}
{% if user == the_user %}
{{ user.name }}
{% endif %}
{% endfor %}
If not, has anyone thought much about this?
Thanks,
Bob
On 30-Jul-08, at 8:05 AM, Bob Hutchison wrote:
>
> Hi,
>
> Let's say you had a general list of things, for the sake of
> simplicity, lets say 'users'. And each user had, at least, a name, so
> this works:
>
> {% for user in users %}
> {{ user.name }}
> {% endfor %}
>
{% for user in users %}
{{ user.name }} {{ user.id }}
{% endfor %}
> Let's say you also have a variable 'the_user' that contained one of
> users contained in users.
make that 'the_user_id'
>
>
> Is there a way to access the name of that user without doing something
> dumb like:
>
> {% for user in users %}
> {% if user == the_user %}
> {{ user.name }}
> {% endif %}
> {% endfor %}
{% for user in users %}
{% if user.id == the_user_id %}
{{ user.name }}
{% endif %}
{% endfor %}
>
>
> If not, has anyone thought much about this?
Should have thought a bit more about the question. Sorry.
>
>
> Thanks,
> Bob
>
>
> >