Re: Iterating tree-like data structures with django

2010-10-08 Thread creecode
Hello all, Bruno was kind enough to list some of the techniques for working with trees. I'd like to throw out another technique you many want to look into if you are working with trees of unknown shape and need frequent inserts/ updates. I've been experimenting with it with some good results so

Re: Iterating tree-like data structures with django

2010-10-08 Thread bruno desthuilliers
On 6 oct, 17:27, Paweł Roman wrote: > I have a model which has a tree-like structure (not exactly a FK on > self but we can assume that's the case). > > I want to visualise this tree using all records from the db. It seems > impossible to do with QuerySet, if I have say 100 records (100 nodes > in

Re: Iterating tree-like data structures with django

2010-10-07 Thread Sam Walters
Also for all your tree related needs there is Django Treebeard: https://tabo.pe/projects/django-treebeard/ On Thu, Oct 7, 2010 at 2:51 AM, Cesar Canassa wrote: > I had the same issue a few months ago. > My only answer to you is that is not worth to develop this all for self. > There is a great

Re: Iterating tree-like data structures with django

2010-10-06 Thread Cesar Canassa
I had the same issue a few months ago. My only answer to you is that is not worth to develop this all for self. There is a great django library called django-mptt that does all the heavy lifting for you. It's very fast, has many helper functions and even

Re: Iterating tree-like data structures with django

2010-10-06 Thread Paweł Roman
Yuck, in_bulk() is useless! I thought it would return a nice dictionary just as expected, but instead it makes me deliver a list of keys first. Why? Eventually I wrote something more usable: mydict = {} for model in MyModel.objects.all().iterator(): mydict[model.id]=model Correct

Re: Iterating tree-like data structures with django

2010-10-06 Thread Paweł Roman
OK, I've got it. It's in_bulk() :) Nevermind the question. On Oct 6, 5:27 pm, Paweł Roman wrote: > I have a model which has a tree-like structure (not exactly a FK on > self but we can assume that's the case). > > I want to visualise this tree using all records from the db. It seems > impossible

Iterating tree-like data structures with django

2010-10-06 Thread Paweł Roman
I have a model which has a tree-like structure (not exactly a FK on self but we can assume that's the case). I want to visualise this tree using all records from the db. It seems impossible to do with QuerySet, if I have say 100 records (100 nodes in the tree) and I try building the tree recursive