Hello all, So I'm making a sort of FAQ, with a hierarchical category structure:
28 class SupportCategory(models.Model): 29 title = models.CharField(max_length=100) 30 slug = models.CharField(max_length=100) 31 parent = models.ForeignKey('self', blank=True, null=True, 32 related_name='children') And Questions can belong to many categories: 55 class Question(models.Model): 56 timestamp = models.DateTimeField(auto_now=True) 57 question = models.TextField() 58 answer = models.TextField() 59 categories = models.ManyToManyField(SupportCategory, 60 related_name='questions') 61 keywords = models.ManyToManyField(Keyword, 62 related_name='questions') 63 attachments = models.ManyToManyField(Attachment, blank=True, 64 related_name='questions') 65 related_questions = models.ManyToManyField('self', blank=True) Obviously, for a given category, cat.questions.all() will return all questions assigned to cat. How can I write a query (or even better, a manager) which will return all questions belonging to cat and all of it's ancestors (cat.children, and their children, etc). Thanks in advance for any suggestions. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.