Daniel Naab
unread,Oct 29, 2011, 2:08:31 PM10/29/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-mptt-dev
Hi Folks,
I've been considering branching django-mptt to support the notion of
multiple trees per node, essentially implementing a more complex
directed graph but maintaining the tree abstraction. Here's the kind
of situation I'm thinking about; does it make sense?
class Node(MPTTModel):
parent = TreeForeignKey('self', null=True, blank=True,
related_name='children')
parent_revision = TreeForeignKey('self', prefix='revision',
null=True, blank=True, related_name='child_revisions')
Essentially, the "prefix" kwarg to TreeForeignKey would instruct the
metaclass to contribute "revision_lft", "revision_rght", etc, fields
to the class instead of "lft", "rght", and also new accessors like
"get_revision_descendent_count()". As you can discern, my use case
involves tracking revision history for nodes in a tree.
This might be opening up a can of worms, when simply having a foreign
key on Node to another tree achieves the same goal. However, this can
be expensive on large trees if you need the second parent reference on
each node. In addition, these really are two trees (although they
could be considered more complex graphs), so the abstraction is nice
and tidy.
Any thoughts or suggestions? Bad idea, or is there another efficient
way to handle this case?
Thanks,
Daniel