Re: Dictionary lookup with variable in template

2007-04-15 Thread tsuraan
> This is so easily taken care of by a filter, I'm not sure if it's > worth the trouble of introducing to the core syntax. > > @register.filter > def objIndex(value, arg): > "Use objects as keys in dictionaries > {{ my_dict|objIndex:Value }}" > return value[arg] > > for exa

Re: Dictionary lookup with variable in template

2007-04-15 Thread tsuraan
> Any thoughts? Ok, so I just tried installing the admin interface, and my code appears to break that in all sorts of interesting ways. So, I guess what I posted is pretty worthless right now. I'm still going to try to get this working though, since I think it should be worthwhile. --~--~-

Dictionary lookup with variable in template

2007-04-14 Thread tsuraan
So, we have the four basic things that a "dot" can imply in a template: dictionary lookup, attribute lookup, method call, and list-index. What I needed was dictionary lookup on the context's value for the given field, rather the literal field. An example might help: >>> import django.template a