views:

137

answers:

0

Dear all,

I'm working on a Django application allowing one to comment either a Text, its Paragraphs or the comments themselves. I'm using the Comment app bundled with Django, and A Text class instance is made up of Inline Paragraph class instances.

I'm desperately looking for a way get back a QuerySet/List of all the Comments related directly or indirectly to a Text, be them attached to the Text instance, its paragraphs or their comments.

I've been looking at QuerySets, Q objects and ContentType objects without beeing able to find a solution. If I have no problem to filter the comments attached to a specific Text...

myText = Text.objects.all()[0]
ctt = ContentType.objects.get(app_label="library", model="text")
print Comment.objects.filter(Q(content_type=ctt), Q(object_pk=myText.id))

... I can't retrieve the comments attached to its Paragraphs...

ctp = ContentType.objects.get(app_label="library", model="paragraph")
print dir(Comment.objects.filter(Q(content_type=ctp), Q(content_object__text=myText))

... And I even didn't tried yet to get back the comments attached to a Paragraph attached to a Text...

Thanks for your help!!!