Hi everybody out there! :-)
I have to cope with a few hundreds item tree/hierarchy in my Django
project. Specifically, I'll have 500 hundreds leaves in a 3-levels
tree with a dozen branches.
I won't need much writing over this tree, I'll just need to read it
and show data in a drop down menu.
I've been told to use django-treebeard or django-mptt to speed up
things, but I wrote down a first draft on my own:
class Node(models.Model):
name = models.CharField(max_length=50)
parent = models.ForeignKey('self')
class Product(models.Model):
name = models.CharField(max_length=50)
parent = models.ForeignKey(Node)
[some more info here]
The point is, how can I create the root of my tree? Should I add some
"blank=True, null=True" properties to my Node model? So to have:
class Node(models.Model):
name = models.CharField(max_length=50)
parent = models.ForeignKey('self', blank=True, null=True)
And then consider the "null-parented" node as the root one?
Does my code make any sense? Do you think it will turn out as too slow
for my hierarchy? Should I better rely on django-treebeard or
django-mptt?
Any help appreciated, thank you so much!
Regards,
--
Fabio Natali
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---