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