Questions tagged [django-treebeard]

django-treebeard is a pluggable django app that implements efficient tree implementations

django-treebeard is a pluggable django app that implements efficient tree implementations:

  • Adjacency List
  • Materialized Path
  • Nested Sets
57 questions
28
votes
1 answer

Django treebeard what are differences between AL, NS, MP

I'm trying to make a model for categorizing some objects. I already tried using django-mptt to easily retrieve related categories, and now I'm searching different solutions to find the best one. I can't find out though what are main differences…
aherok
  • 622
  • 7
  • 17
14
votes
3 answers

What are the advantages of django-treebeard over django-mptt?

There are two well known Django packages for creating tree structures: django-treebeard and django-mptt. Recently Django CMS started using django-treebeard instead of django-mptt. Wagtail CMS is also using django-treebeard. What makes…
Aidas Bendoraitis
  • 3,965
  • 1
  • 30
  • 45
6
votes
0 answers

What is proper way to link django-treebeard model with another django model as foreignkey?

I'm building a system which will show important facilities around every stadium in a city like depots,railway stations, hospitals, restaurants and bars etc and their distances from respective stadium. I've two models in Django, one for Stadium and…
5
votes
2 answers

Is it possible to integrate django-taggit and django-mptt / django-treebeard?

I am developing a website that requires tagging up different types of content, which favors using django-taggit. But, it would be extremely beneficial if the tags were represented in the database in their natural hierarchy, favoring use of…
5
votes
4 answers

Django: How do I model a tree of heterogeneous data types?

I need to store a tree data structure in my database, for which I plan on using django-treebeard or possibly django-mptt. My source of confusion is that each node could be one of three different possible types: root nodes will always be a type A…
Corey
  • 14,101
  • 7
  • 38
  • 35
5
votes
2 answers

Adjacency List Tree Using Recursive WITH (Postgres 8.4) instead of Nested Set

I'm looking for a Django tree library and doing my best to avoid Nested Sets (they're a nightmare to maintain). The cons of the adjacency list model have always been an inability to fetch descendants without resorting to multiple queries. The WITH…
Koobz
  • 6,928
  • 6
  • 41
  • 53
4
votes
1 answer

How to prevent N+1 queries when fetching ancestors with Django Treebeard?

We are using Django Treebeard's materialized path to model an organizational hierarchy as follows: Now each node in the organizational tree can have multiple tasks: class Organization(MP_Node): node_order_by = ['name'] name =…
4
votes
1 answer

Adding default tags via data migration

I am using hierarchical tags which work with taggit and treebeard. I am trying to get a data migration so I can define so tags that will be present in all instances of the app. I have this method defined: def define_tags(apps, schema_editor): …
Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156
4
votes
4 answers

Searching for the right-most node of a materialized path tree

Is it possible to sort by a materialized path tree's path text field in order to find the right-most node of the tree? For example, consider this python function that uses django-treebeard's MP_Node: def get_rightmost_node(): """Returns the…
nnyby
  • 4,748
  • 10
  • 49
  • 105
3
votes
1 answer

Dynamic ordering of django-treebeard materialized path nodes

I have a project based on django-oscar (and django-cms), which runs on multiple domains with different SITE_IDs using the django.contrib.sites module. The project is already productive and i can't change the category slugs anymore - Also switching…
wiesion
  • 2,349
  • 12
  • 21
3
votes
2 answers

How to prefetch descendants with django-treebeard's MP_Node?

I'm developing an application with a hierarchical data structure in django-rest-framework using django-treebeard. My (simplified) main model looks like this class Task(MP_Node): name = models.CharField(_('name'), max_length=64) started =…
Matthijs Brouns
  • 2,299
  • 1
  • 27
  • 37
3
votes
3 answers

How to get all descendants of a node with Django treebeard?

Let's say I have these Models: class Category(MP_Node): name = models.CharField(max_length=30) class Item(models.Model): category = models.ForeignKey(Category) and I would like to find all Items belonging to any descendant of a given…
Alex Rothberg
  • 10,243
  • 13
  • 60
  • 120
3
votes
3 answers

Treebeard admin in Django

I've setup Treebeard in Django and everything seems to have gone well. I tried to setup the admin system and I can see my models being presented in the admin interface. However, when I try to add new data using the admin interface, I get the…
Sharath
  • 31
  • 2
2
votes
2 answers

How to display django-treebeard MP in template as dropdown menu?

Following the treebeard docs api example, I created an annotated_list of my tree using get_annotated_list(parent=None, max_depth=None) with parent=. I pass this to my template and using the example they attribute in the docs to Alexey…
amy
  • 354
  • 1
  • 9
2
votes
0 answers

Checking tree modifications in django-treebeard ORM before saving

I want to double-check if I am correctly interpreting the following section of the django-treebeard docs: django-treebeard uses Django raw SQL queries for some write operations, and raw queries don’t update the objects in the ORM since it’s being…
gatlanticus
  • 1,158
  • 2
  • 14
  • 28
1
2 3 4