Re: Help Converting a Query getting one result using .filter() to .get()

2010-07-13 Thread Chris McComas
Sorry, I should've said what I'm using it for...

Here's my models http://dpaste.com/217686/

The query above I just want to get the next/upcoming game in the
database, which I display on the sidebar of the front page. What I am
trying to do, is also get ALL other entries from the database, in a
separate query where sport=sport and opponent=opponent to figure out
the historical Win/Loss record between the teams?



On Jul 12, 8:15 pm, John M  wrote:
> Why does it matter?
>
> You could just say next_game[0] instead.
>
> J
>
> On Jul 12, 4:28 pm, Chris McComas  wrote:
>
>
>
> > I have this query, trying to get the next game in the future.
>
> > today = datetime.datetime.now()
> > next_game = Game.objects.filter(date__gt=today).order_by('date')[:1]
>
> > I need to use .get() if possible, instead of .filter() how can I do
> > this?

-- 
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.



Re: Help Converting a Query getting one result using .filter() to .get()

2010-07-12 Thread John M
Why does it matter?

You could just say next_game[0] instead.

J

On Jul 12, 4:28 pm, Chris McComas  wrote:
> I have this query, trying to get the next game in the future.
>
> today = datetime.datetime.now()
> next_game = Game.objects.filter(date__gt=today).order_by('date')[:1]
>
> I need to use .get() if possible, instead of .filter() how can I do
> this?

-- 
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.



Help Converting a Query getting one result using .filter() to .get()

2010-07-12 Thread Chris McComas
I have this query, trying to get the next game in the future.

today = datetime.datetime.now()
next_game = Game.objects.filter(date__gt=today).order_by('date')[:1]

I need to use .get() if possible, instead of .filter() how can I do
this?

-- 
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.