On Feb 19, 8:04 am, Daniel Wong <allyourc...@gmail.com> wrote: > Seems like there's no good way to do this, because you can't call > methods that take > 0 arguments. > > Here's an example of the sort of thing I'm trying to do. Imagine > you're trying to create a spreadsheet like view: > > {% for person in people %} > <tr> > {% for col in columns %} > <td>{{ person.get(col) }}</td> > {% endfor %} > {% endfor %} > > Seems like you'd have to use custom tags to achieve this, but that > seems way too complicated for something so simple. Is there a better > way?
Writing a custom filter for this is the correct way - and it's a three- line job: @register.filter def get_obj(obj, value): return obj.get(value) -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.