I have these two models:

class GradeBookColumn(models.Model):
    assignment = models.ForeignKey(Assignment, 
                related_name='grade_book_columns')
    section = models.ForeignKey(Section)
    when_assigned = models.DateTimeField(blank=True, null=True)
    when_due = models.DateTimeField()
    
class Grade(models.Model):
    grade_book_column = models.ForeignKey(GradeBookColumn)
    student = models.ForeignKey(User)
    when_recorded = models.DateTimeField(auto_now=True)
    points = models.FloatField(max_digits=6, decimal_places=2)

I'm trying to get all the grades that belong to a certain student in a
certain section and order them by when the assignments were due.

grades = Grade.objects.filter(student=user,
        grade_book_column__section=section).order_by(
        'grade_book_column__when_due')

didn't work. (Wouldn't it be cool if it did?) So I went to the docs and
discovered I had to use a dot between the other table and its field. So
I tried

grades = Grade.objects.filter(student=user,
        grade_book_column__section=section).order_by(
        'grade_book_column.when_due')

but that didn't work either.

What am I doing wrong?

Todd



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to