Hello,
While writing a forum app, I ran into a problem: I am unable to sort a
list of threads by date of their latest post.
My models look like:
class Thread(models.Model):
club = models.ForeignKey(Club)
name= models.CharField(_('Thread'), max_length=100)
date = models.DateTimeField(auto_now = True )
def __unicode__(self):
return self.name
class Post(models.Model):
thread = models.ForeignKey(Thread)
date = models.DateTimeField(auto_now=True)
subject = models.CharField(_('Subject'), max_length=100)
text = models.TextField(_('Text'))
def __unicode__(self):
return self.subject
I know that I can get the date of the latest post of a thread by
using:
Thread.objects.get(id=3).post_set.all().latest('date').date
However, I do not know if there is any possibility of me using that
date to sort a QuerySet of threads, which I get by using
Thread.objects.filter(club=1). Is there any way to do this in Django?
Many thanks for your help!
Wim
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---