This is the third time this issue has come up in the last day :)
Try this, since it'll work for dictionaries, lists, and objects:

from django.template import resolve_variable
@register.filter
def lookup(value, key):
return resolve_variable(key,value)

-Justin

On Fri, Mar 7, 2008 at 6:20 PM, Nick Fishman <[EMAIL PROTECTED]>
wrote:

>
> Malcolm Tredinnick wrote:
> > I wouldn't be too surprised if something like that already existed at
> > djangosnippets.org, but, if not, it should be only a couple of lines to
> > write one.
> >
> Thanks, Malcom. A friend of mine found something that's exactly like
> what you were talking about:
>
> http://push.cx/2007/django-template-tag-for-dictionary-access
>
> It's very painless and effective. It would be nice to see a tag like
> this included by default - it would have saved me lots of headaches
> earlier. Julien mentioned that this is bad practice, but I don't really
> understand how. Especially if the alternative is using numbered tuples
> or nesting more and more dictionaries inside of dictionaries.
>
> Thanks for the push in the right direction!
>
> Nick
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to