Re: django queryset get only one result for one column pair

2010-08-14 Thread Rohan Jain
My models are defined like this: class Problem(models.Model): title = models.CharField('Title', max_length = 100) question = models.TextField('Question') class Submission(models.Model): user = models.ForeignKey(User) problem = models.ForeignKey(Problem) solution =

Re: django queryset get only one result for one column pair

2010-08-14 Thread Nick
http://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct Distinct() may be what you're looking for to returns distinct values for each problem. Or, petter yet, you could use .latest() So Submission.objects.all().latest('problem').distinct()

Re: django queryset get only one result for one column pair

2010-08-14 Thread Rohan Jain
On Aug 14, 5:57 pm, Kenneth Gonsalves wrote: > On Sat, 2010-08-14 at 05:45 -0700, Rohan Jain wrote: > > I have a field 'submission' which has a 'user' and a 'problem'. > > How can i get a django queryset search result which will give a list > > of only one result per

Re: django queryset get only one result for one column pair

2010-08-14 Thread Rohan Jain
Actually there may be many submissions with a user-problem pair but i want to list only the last one per user - problem pair. Like: let p1 be two problems , u1, u2 be two users and s1,s2 two submissions by user u1 on problem and s3,s4 by u2. so i want to get a queryset with only the last

Re: django queryset get only one result for one column pair

2010-08-14 Thread Kenneth Gonsalves
On Sat, 2010-08-14 at 05:45 -0700, Rohan Jain wrote: > I have a field 'submission' which has a 'user' and a 'problem'. > How can i get a django queryset search result which will give a list > of only one result per user-problem pair. does your model not have a unique_together for user and

django queryset get only one result for one column pair

2010-08-14 Thread Rohan Jain
I have a field 'submission' which has a 'user' and a 'problem'. How can i get a django queryset search result which will give a list of only one result per user-problem pair. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this