title: In Django how can I search for related models based on the order they were added to a ManyToMany Field?
body: <p>I have a model that has several manytomany relationships to it's self. The model has 1 parent, Many children, 1 greatgreat......grand parent . I want to keep the chain of parents stored on the model so I can simply search for objects that have a certain user associated with them to find to quickly find decendents on any level. What I want to know is how can I detrime what position they land on in the manytomany relationship.
  so the model would look something like this(not actual code):</p>
  
  <pre><code>class Person:
  user = onetoone(user)
  greatgrandparent7generationsup = foreign(Person)
  parents = many(user.user_name) //Geneology dad, grandad, greatgrandad ..... 
  </code></pre>
  
  <p>I have the code that would add the geneology in order, that's no problem.
  I can figure out how to find all the decendents someone has.
  What I want to be able to do is find out is once I have that decendant I want to know where in the liniege they lie(by determinging the if their the 1st 2nd 3rd .... model in the parents field). I'm trying to avoid a depth-first search. That's why I'm doing it like this.</p>