Correct way to model recursive relationship in Django

Posted by Yuval A on Stack Overflow See other posts from Stack Overflow or by Yuval A
Published on 2010-03-20T14:08:04Z Indexed on 2010/03/20 14:11 UTC
Read the original article Hit count: 331

Filed under:
|

My application has two node types: a parent node which can hold recursive child nodes. Think of it like the post-comment system in SO, but comments can be recursive:

parent_1
  child_11
  child_12
    child_121
  child_3
parent_2
  child_21
    child_211
      child_2111

Important to note that the parent nodes have different attributes and behavior than the child nodes.

What is the correct (and presumably most efficient) way of modeling this relationship in Django?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models