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 :)


Thank you for your help

On May 2, 8:02 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On May 2, 3:39 pm, Vedlen <ved...@hotmail.de> wrote:
>
>
>
>
>
> > Hi everybody,
>
> > I started working with Django very recently and I'm basically a PHP
> > developer so I'm pretty much confused with lots of different things
> > right now as I'm getting used to Django ;)
>
> > Here's my problem :
>
> > First off, I fetch values from my database :
> > s = Score.objects.filter(blablabla).order_by(blablabla)
>
> > but among the fields returned above there's this one field called
> > "moment" for which I need all occurences to be passed through a
> > function called "DateFr()". However I can't call a function in the
> > template, and I'm somehow not able to perform a "for ... in s" as
> > Django returns " 'Score' object is unsubscriptable "
>
> > Could anyone help me out with this?
>
> > Thank you very much :]
>
> > Vedlen
>
> I think you might need to post some more code, as the line you have
> posted has 'filter' and that always returns a queryset, but you
> somehow seem to have got a single Score instead.
>
> However, if you're sure you only need the 'moment' field and none of
> the others, you might try this:
> moments = Score.objects.filter(blablah).order_by(blahblah).values_list
> ('moment', flat=True)
> which just returns a list of all the moment fields.
> --
> 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-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
-~----------~----~----~----~------~----~------~--~---

Reply via email to