Reputation: 5371
I have the following tables:
class Note(model):
note_data = models.ForeignKey(NoteData)
important = models.BooleanField(default=0)
deleted = models.DateTimeField(null=True)
deleted_by = models.ForeignKey(User, null=True)
class NoteData(model):
created = models.DateTimeField(default=datetime.now)
created_by = models.ForeignKey(User, null=True)
note = models.TextField()
How do I list all notes by oldest first?
Upvotes: 1
Views: 83
Reputation: 599580
Note.objects.all().order_by('note_data__created')
This is fully documented.
Upvotes: 2