Re: Query with no-correspondence results

2011-12-26 Thread Python_Junkie
I have not read all 18 responses, so if I am off base I apologize. I believe that you want to avg the votes (by gender) of each unique combination of thing and context. (First take gender out of the equation) In order to be able to get the avg votes for the combination of potatoes and flavor as

Re: Query with no-correspondence results

2011-12-26 Thread wgis
Sorry for digging this up but I have a more complex funcionality to implement and I was hoping you could help I had mydatabase_votecontext (id, name) (1, Flavour) (2, Smell) (3, Usability) (4, Size) mydatabase_vote (id, thing, context, user, vote) (1, Potatoes, Flavour, Me, 2.0) (2, Potatoes,

Re: Query with no-correspondence results

2011-12-11 Thread wgis
hmm.. I did not take that into consideration. I'm using MySQL. That's unfortunately, indeed it was doing what I asked for. Well, thank you both. My project is more in tune now. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: Query with no-correspondence results

2011-12-09 Thread Tom Evans
On Thu, Dec 8, 2011 at 8:45 PM, wgis wrote: > Ian Clelland, it worked! Thanks a lot for your perseverance > > Tom's secret sauce it's not working, unfortunately =( > Just (Carrots, Flavour, 3.0) > I guess since some 'contexts' don't have an associated thing-vote, the >

Re: Query with no-correspondence results

2011-12-08 Thread Ian Clelland
On Thu, Dec 8, 2011 at 12:45 PM, wgis wrote: > Ian Clelland, it worked! Thanks a lot for your perseverance > > Tom's secret sauce it's not working, unfortunately =( > Just (Carrots, Flavour, 3.0) > I guess since some 'contexts' don't have an associated thing-vote, the >

Re: Query with no-correspondence results

2011-12-08 Thread wgis
Ian Clelland, it worked! Thanks a lot for your perseverance Tom's secret sauce it's not working, unfortunately =( Just (Carrots, Flavour, 3.0) I guess since some 'contexts' don't have an associated thing-vote, the filter will cut them off. It would be more neat with the ORM, but I must be looking

Re: Query with no-correspondence results

2011-12-07 Thread Ian Clelland
On Wed, Dec 7, 2011 at 7:54 AM, wgis wrote: > First, thank you both for your answers. I'm now realizing that doing > this with the ORM is not so easy as I thought it would be to others > django fellows (it's my first django project, but I'm nailing it =P). > I saw your RAW

Re: Query with no-correspondence results

2011-12-07 Thread Tom Evans
On Wed, Dec 7, 2011 at 5:09 PM, Tom Evans wrote: > Isn't this the secret sauce he is looking for? > Of course, I forget that the OP also wants to filter by a specific user: >>> qs = VoteContext.objects.filter((Q(vote__thing=carrot) | >>> Q(vote__isnull=True)) &

Re: Query with no-correspondence results

2011-12-07 Thread Tom Evans
On Tue, Dec 6, 2011 at 9:35 PM, Reinout van Rees wrote: > On 06-12-11 21:11, wgis wrote: >> >> I get >> (Carrots, Flavor,2.0) >> >> I want to list all the contexts in the "Carrot template", withou >> having to search and merge the ones missing. >> So if the result was >> >>

Re: Query with no-correspondence results

2011-12-07 Thread wgis
First, thank you both for your answers. I'm now realizing that doing this with the ORM is not so easy as I thought it would be to others django fellows (it's my first django project, but I'm nailing it =P). I saw your RAW SQL solution and it looked genius-simple. I have short experience with the

Re: Query with no-correspondence results

2011-12-06 Thread Reinout van Rees
On 06-12-11 22:48, Ian Clelland wrote: Raw SQL: select thing, name, vote from mydatabase_votecontext left join mydatabase_vote on (mydatabase_vote.context_id = mydatabase_votecontext.id ) where thing='Carrot' and user='Me' That should return null if there is no

Re: Query with no-correspondence results

2011-12-06 Thread Ian Clelland
On Tue, Dec 6, 2011 at 1:35 PM, Reinout van Rees wrote: > Ah! Now I get your point. You also want the "empty" results for which > there's no SQL data. Sorry, but I don't see a way in which you can do that > with an SQL query (and so also not with a Django query). > > In case

Re: Query with no-correspondence results

2011-12-06 Thread Reinout van Rees
On 06-12-11 21:11, wgis wrote: I get (Carrots, Flavor,2.0) I want to list all the contexts in the "Carrot template", withou having to search and merge the ones missing. So if the result was (Carrots, Flavour, 2.0) (Carrots, Smell, 0.0) (Carrots, Usability, 0.0) (Carrots, Size, 0.0) or

Re: Query with no-correspondence results

2011-12-06 Thread Andre Terra
I'll admit that I read through the thread in about a minute, so forgive me if I'm completely off, but isn't this something that can be solved through aggregation[1]? And you don't want votes, but rather *contexts*, because all of these matter to you, whereas votes can be 0 (default). Speaking of

Re: Query with no-correspondence results

2011-12-06 Thread wgis
I get (Carrots, Flavor,2.0) I want to list all the contexts in the "Carrot template", withou having to search and merge the ones missing. So if the result was (Carrots, Flavour, 2.0) (Carrots, Smell, 0.0) (Carrots, Usability, 0.0) (Carrots, Size, 0.0) or (Carrots, Flavour, 2.0) (Carrots, Smell,

Re: Query with no-correspondence results

2011-12-06 Thread Reinout van Rees
On 06-12-11 06:43, wgis wrote: But then I would have something like (Carrots, Flavor,2.0) as the result instead of the desired (Carrots, Flavour, 2.0) (Carrots, Smell, 0.0) (Carrots, Usability, 0.0) (Carrots, Size, 0.0) That's the same, right? At least,

Re: Query with no-correspondence results

2011-12-05 Thread wgis
Hey Renout, thanks for your answer. But then I would have something like (Carrots, Flavor,2.0) as the result instead of the desired (Carrots, Flavour, 2.0) (Carrots, Smell, 0.0) (Carrots, Usability, 0.0) (Carrots, Size, 0.0) or (Carrots, Flavour, 2.0) (Carrots, Smell, null) (Carrots,

Re: Query with no-correspondence results

2011-12-05 Thread Reinout van Rees
On 05-12-11 23:10, wgis wrote: Hi guys, I'm trying to solve this without raw SQL, from the past 4/5 days. I've been also researching a lot to understand more complex queries in django so I would realy appreciate your help since I plan to continue using django in my projects. I have a: class

Query with no-correspondence results

2011-12-05 Thread wgis
Hi guys, I'm trying to solve this without raw SQL, from the past 4/5 days. I've been also researching a lot to understand more complex queries in django so I would realy appreciate your help since I plan to continue using django in my projects. I have a: class VoteContext(models.Model):