The joy of annotate(). In Django 1.1 and above:
result = Student.objects.annotate(latest = models.Max('grades__date'))
gives you the recordset, sans test_name. Any advances on this?
On Jan 28, 1:57 pm, Michael Shepanski <[email protected]> wrote:
> Is it possible to code this scenario using the Django ORM?
>
> I have two tables:
> STUDENT: id, name, address
> GRADES: id, student_id, date, test_name, grade
>
> Each Student will have several entries in the Grades table. I am
> wondering if it is possible using Django's ORM to select all students
> along with their *latest* grade information. I basically want a result
> table that looks like the following, where date, test_name, and grade
> are for the latest result (by date).
>
> LATEST_GRADES: id, name, address, date, test_name, grade
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.