开发者

[django]How to get topics user replied?

class Topic(models.Model):
    title = models.CharField(max_length=100)
    body  = models.TextField(_('body'), max_length=TEXT_MAX_LENGTH)
    user  = models.ForeignKey(User, related_name='topic_user', editable=False)
    ...

I use 'django.contrib.comments' to reply开发者_运维问答 a topic. How to get topics I replied(just know my user id)?

Thanks.


It works:

Topic.objects.filter(pk__in=[comment.content_object.pk for comment in Comment.objects.filter(user__exact = request.user)])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜