Datastructure using django.

33 views
Skip to first unread message

Subhodip Biswas

unread,
Dec 10, 2012, 1:15:41 PM12/10/12
to django...@googlegroups.com
Hi all,

I am trying to implement a tree structure using django. There are two packages I am looking at mptt and treebeard. Treebeard seems easy.

I have however two questions:

1. With mptt I found that if you have moved one child to another parent both db and instance is updated but you need to reload or reregister every time you call such action.Is there a better way of doing this?

2. If my child have more than one parent, the structure does not remain a tree anymore. It becomes a graph i guess, How do you handle such situation.

3. How do I add treebeard or mptt into django admin. If I have one field name and I register it in admin.py. I get error regarding depth,path, numchild and name should be present. How do I handle this situation.

Apologies for asking so many questions.


-------------
Regards
Subhodip Biswas


GPG key : FAEA34AB
Server : pgp.mit.edu
http://subhodipbiswas.wordpress.com
http:/www.fedoraproject.org/wiki/SubhodipBiswas

Chris Cogdon

unread,
Dec 12, 2012, 4:24:43 PM12/12/12
to django...@googlegroups.com
I've no answers for you, but you might want to have a look at other applications that use those products and see how they work.

I know that "zinnia", a Django-based blog framework, uses "mptt", so you might want to have a look there. I've used zinnia, and I've never had to do any "reload" so to speak when I add in categories into the tree.

b1-

unread,
Dec 12, 2012, 10:48:44 PM12/12/12
to django...@googlegroups.com


On Monday, December 10, 2012 8:15:41 PM UTC+2, Subhodip Biswas wrote:
Hi all,

I am trying to implement a tree structure using django. There are two packages I am looking at mptt and treebeard. Treebeard seems easy.

I have however two questions:

1. With mptt I found that if you have moved one child to another parent both db and instance is updated but you need to reload or reregister every time you call such action.Is there a better way of doing this?

This is normal for django because for site prefarable structure with faster reading than faster writing.

2. If my child have more than one parent, the structure does not remain a tree anymore. It becomes a graph i guess, How do you handle such situation.

mptt has 'TreeManyToManyField' so I think this is possible
 
3. How do I add treebeard or mptt into django admin. If I have one field name and I register it in admin.py. I get error regarding depth,path, numchild and name should be present. How do I handle this situation.

For me this works

# admin.py
from django.contrib import admin
admin.site.register(ModelName)
 

Can you post your code and errors
Reply all
Reply to author
Forward
0 new messages