[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)])
精彩评论