On Tue, 2008-07-15 at 11:24 -0700, Alex wrote: [...] > So my view throws out a list of teams, filtered to the person and my > template looks like this: > > {% for t in teams %} > {% for s in t.getStats %} > ** I WANT TO NOW DO SOMETHING LIKE: ** > {% for v in s.getStatValues(Person,s) %) > ** EXCEPT THAT I CAN'T PASS ARGS IN A TEMPLATE. ** > > But if I don't pass in those arguments I'll get all the statValues for > everyone on the team, not just the person I'm looking at.
One fairly normal solution is to write a method that returns the results you want (in a format you can use). For example, you're passing in "s" as an argument to a method on "s", which is usually redundant. So you can write a method that works on "self" there by default. And that method could also know that it should work with "Person" (whatever that is). So, it's a custom method for this case. Alternatively, if the method is purely presentational and not particularly related to whatever object "s" is, write a filter function. Filters can take arguments. So something like: {% for v in s|getStats:"person" %} That way, the getStats() function is divorced from s, but it takes "s" and "person" as two arguments. Regards, Malcolm. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---