Hoi,
What about using the Jinja approach?
{{ foo.bar.baz }}
is the same as
{{ foo['bar']['baz'] }}
So it's possible to use variables using this (where bar is a
variable):
{{ foo[bar].baz }}
Regards,
Armin
--~--~-~--~~~---~--~~
You received
On Apr 15, 3:00 pm, tsuraan <[EMAIL PROTECTED]> wrote:
> So {{my_dict | objIndex:Value}} will evaluate Value in the context of
> the current Context, and then pass it to the filter? The HTML
> Template guide says that the argument must be in double quotes, so I
> assume it has to be a literal, ra
> 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
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 example, is probably
> 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.
--~--~-
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