On Tue, Mar 4, 2008 at 11:23 AM, Lauri Ahonen <[EMAIL PROTECTED]> wrote:
> Exactly. This seemed like such a basic concept (select from array based on
> variable value) that I was sure that it's hidden in django somewhere. I
> can't be the first one to need this?

Yes and no. The thing is that a Python translation of it would be
expecting to do something like:

s = 'FOO'
attr_name = 'lower'
s.attr_name()

Which would throw an AttributeError; instead, in *Python*, you need to do

getattr(s, attr_name)()

The solution, if and when you need this, is to use a template filter
that can do the equivalent of getattr(); I believe there's one on
djangosnippets.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to