Re: filtering query on a function

2010-02-01 Thread Kenneth Gonsalves
On Monday 01 Feb 2010 4:34:22 pm Dennis Vermeulen wrote: > > probably - but anyway I do not think django allows functions to be used > > on the left hand side of filters. > > > > Isn't this possible by using > player__handicap__handicapindex__range=[0..16] as filter? > well, the handicapinde

Re: filtering query on a function

2010-02-01 Thread Kenneth Gonsalves
On Monday 01 Feb 2010 6:26:16 pm Daniel Roseman wrote: > > as already mentioned, I am doing it - just hoped that maybe there was a > > shortcut somewhere ... > > Maybe you could denormalize a bit, to store the value of > getcoursehandicap() in the Player model and update it on save. Then > you can

Re: filtering query on a function

2010-02-01 Thread Daniel Roseman
On Feb 1, 11:29 am, Kenneth Gonsalves wrote: > On Monday 01 Feb 2010 4:03:26 pm James Bennett wrote: > > > On Mon, Feb 1, 2010 at 3:59 AM, Kenneth Gonsalves wrote: > > > Anyway, player.getcoursehandicap() works - but not within 'filter' > > > Why would you expect it to? Python method definitions

Re: filtering query on a function

2010-02-01 Thread Dennis Vermeulen
On 1-2-2010 10:59, Kenneth Gonsalves wrote: > On Monday 01 Feb 2010 3:08:57 pm Daniel Roseman wrote: > >>> players = Matchentry.objects.filter(player__getcoursehandicap()__in= >>> [0..16]) >>> >>> of course this doesnt work - any clue how to do this? or do I fall back >>> on raw sql? >>>

Re: filtering query on a function

2010-02-01 Thread Alexandru Nedelcu
On Mon, 2010-02-01 at 04:33 -0600, James Bennett wrote: > On Mon, Feb 1, 2010 at 3:59 AM, Kenneth Gonsalves wrote: > > Anyway, player.getcoursehandicap() works - but not within 'filter' > > Why would you expect it to? Python method definitions are not legal > SQL, so you can't pass a Python metho

Re: filtering query on a function

2010-02-01 Thread Kenneth Gonsalves
On Monday 01 Feb 2010 4:03:26 pm James Bennett wrote: > On Mon, Feb 1, 2010 at 3:59 AM, Kenneth Gonsalves wrote: > > Anyway, player.getcoursehandicap() works - but not within 'filter' > > Why would you expect it to? Python method definitions are not legal > SQL, so you can't pass a Python method

Re: filtering query on a function

2010-02-01 Thread James Bennett
On Mon, Feb 1, 2010 at 3:59 AM, Kenneth Gonsalves wrote: > Anyway, player.getcoursehandicap() works - but not within 'filter' Why would you expect it to? Python method definitions are not legal SQL, so you can't pass a Python method into a SQL query and expect it to work. If you want to further f

Re: filtering query on a function

2010-02-01 Thread Kenneth Gonsalves
On Monday 01 Feb 2010 3:08:57 pm Daniel Roseman wrote: > > players = Matchentry.objects.filter(player__getcoursehandicap()__in= > > [0..16]) > > > > of course this doesnt work - any clue how to do this? or do I fall back > > on raw sql? > > This is impossible to answer without knowing what getcour

Re: filtering query on a function

2010-02-01 Thread Daniel Roseman
On Feb 1, 9:28 am, Kenneth Gonsalves wrote: > hi, > > I have a model Player which has a function called getcoursehandicap() defined > in the model. I need to get all the Players in a Match with course handicap in > a certain range. The query should look like this: > > players = Matchentry.objects.

filtering query on a function

2010-02-01 Thread Kenneth Gonsalves
hi, I have a model Player which has a function called getcoursehandicap() defined in the model. I need to get all the Players in a Match with course handicap in a certain range. The query should look like this: players = Matchentry.objects.filter(player__getcoursehandicap()__in= [0..16]) of co