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()

http://www.djangoproject.com/documentation/models/get_latest/
On Aug 14, 8:04 am, Rohan Jain <rohanjain....@gmail.com> wrote:
> 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 submission by u1,u2 on
> p1.
>
> On Aug 14, 5:57 pm, Kenneth Gonsalves <law...@au-kbc.org> 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 user-problem pair.
>
> > does your model not have a unique_together for user and problem?
> > --
> > regards
> > Kenneth Gonsalves

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

Reply via email to