Re: does TreeManyToManyField imply multiple parents?

512 views
Skip to first unread message

Craig de Stigter

unread,
Nov 4, 2012, 1:35:52 PM11/4/12
to django-...@googlegroups.com
Hi Brian

MPTT is specifically for dealing with trees, which means each node can only have one parent.

You may need to either change your model somewhat, or look at using a graph database.

Apologies for the late reply, just saw the pending message on google groups.

Craig

On Sat, Nov 3, 2012 at 1:25 AM, Brian Hicks <thereal...@gmail.com> wrote:
Hi,

I'm trying to use django-mptt for multiple parents in the tree. It seems that TreeManyToManyField would satisfy this, but I can't find any documentation about it. My understanding of the MPTT algorithm is that this might screw everything up pretty badly as well. Is this the way to go?

Craig de Stigter

unread,
Nov 4, 2012, 2:39:43 PM11/4/12
to django-...@googlegroups.com
It just prescribes a default formfield that adds indentation and correct ordering.

So if you use it when pointing to an MPTTModel subclass then you don't need to do anything to get forms and admin working properly.

Otherwise it's just the same as a normal ManyToMany.

Craig

On Mon, Nov 5, 2012 at 8:25 AM, Brian Hicks <thereal...@gmail.com> wrote:
Thanks. If you don't mind answering though, what *does* TreeManyToManyField do?

Daniel Naab

unread,
Nov 4, 2012, 5:01:24 PM11/4/12
to django-...@googlegroups.com
I started something along these lines about a year ago:


As I recall, it was passing tests for single-tree nodes, but there was some meta-class magic that was still failing with multi-tree nodes, or some edge cases that weren't working.  I stopped development shortly after starting because I came to the conclusion that it was the wrong data model for my problem, but it may be a starting point for someone else.

Daniel
Reply all
Reply to author
Forward
0 new messages