On Mon, 2006-10-09 at 14:41 +0200, patrickk wrote:
> some more details:
> 
> my posting-model:
> 
> class Posting(models.Model):
>      title = models.CharField('Titel', maxlength=200)
>      ...
>      user = models.ForeignKey(User)
>      ...
> 
> so, every posting is connected to a user.
> question is, how do I get the latest comments for postings by that user?
> 
> usually, I´d write something like:
> Comment.objects.filter(object__user=userid)
> 
> but since comment doesn´t know what object_id is referring to, that  
> doesn´t work.

You might be able to construct something using the extra() method on
querysets. Start off with a Queryset that gets the comments for your
Posting object_id. Pass in the table for the Posting model and an extra
where clause, for example. Should be possible, but it might take a bit
of fiddling and examining the contents of django.connection.queries to
get it perfectly correct. The logic behind this is that you know where
the extra information resides and so you can manually do the join.

Regards,
Malcolm

> 
> thanks,
> patrick
> 
> 
> Am 06.10.2006 um 17:47 schrieb patrickk:
> 
> >
> > I´m currently trying to use the comment framework and I´m trying to
> > retrieve the last 10 comments given for postings by a specific user.
> >
> > the lookup I´d like to have is:
> >
> > select * from comments
> > join posting on comments.object_id = postings.id
> > join user on posting.user_id = user.id
> >
> > more detailed:
> >
> > I´m on the weblog-site of a user, so I have the users id (which is
> > different from the logged-in user).
> > this user has postings and there are comments to this postings.
> > now, I´d like to have a list with the last 10 comments on this users
> > postings.
> >
> > I hope this is not too confusing.
> >
> > thanks,
> > patrick
> > >
> 
> 
> > 
> 


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

Reply via email to