1

I don't want to iterate through the dictionary. I have a key, and simply want to return the value for that key if it exists.

I'm not getting any results.

users // a dictionary of user_ids and values user.key // a user id. {{ users.user.key }} 

This displays nothing when I know the value for the key passed exists.

1 Answer 1

4

The problem is that Django interprets users.user.key as users.user[key], which of course is not what you want.

You can use with directive to work around this.

 {% with user.key as user_key %} {{users.user_key}} {% endwith %} 
Sign up to request clarification or add additional context in comments.

2 Comments

I'm on GAE which has Django 0.96 I think, and that's not working. Maybe I need to create a custom filter.
For what it is worth this does not actually look like it works for Django 1.4.x. I've been told that this is not something that is supported. If this works it must require some additional filter that is not listed as a part of this answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.