On 5/2/2009 6:24 PM, Vedlen wrote: > I've got multiple tuples, and I need all the fields. > I just need to pass all the "moment" fields from the tuples, into my > function. > > Here is what my template looks like : > > <table> > {{ for s in Score }} > <tr><td>{{ s.moment }}</td><td>{{ s.someOtherField }}</td></tr> > {{ endfor }} > </table> > > > It's like I'd need to do this : > > <table> > {{ for s in Score }} > <tr><td>{{ DateFr(s.moment) }}</td><td>{{ s.someOtherField }}</td></ > tr> > {{ endfor }} > </table> > > but it doesn't work since you can't call functions in templates :( so > I need to alter the "moment" fields before getting to the template > thing, you know what I mean. It's a pretty basic task when you know > Django pretty well though, but I don't :)
I think the easiest solution for you is to write a custom method on your Score model: {{{ class Score(models.Model): <normal model stuff> def date_fr_moment(self): return DateFr(self.moment) }}} In your template, you can just access it with s.date_fr_moment. -- George --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---