[Djula] Indirect access of variable names

1 view
Skip to first unread message

Bob Hutchison

unread,
Jul 30, 2008, 8:05:54 AM7/30/08
to cl-te...@googlegroups.com, Bob Hutchison
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 %}

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

Bob Hutchison

unread,
Jul 30, 2008, 8:11:22 AM7/30/08
to cl-te...@googlegroups.com, Bob Hutchison
Okay, just to be more to the point...

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
>
>
> >

Reply all
Reply to author
Forward
0 new messages