Questions tagged [django-mptt]

django-mptt is an implementation Modified Preorder Tree Traversal for handling trees of Django Model instances.

django-mptt is an implementation Modified Preorder Tree Traversal for handling trees of Django Model instances.

Useful links:

351 questions
1
vote
1 answer

Extract children with a given condition - Django MPTT and Django rest framework

In this tree I want to do a query so that only the first generation of the red circle is extracted. But the condition is that the value of each circle must be greater than zero, ie the green circles: Serializers: class…
mrbf
  • 512
  • 1
  • 7
  • 23
1
vote
0 answers

Signal attached to 3rd party library model not being triggered

I've have got a usecase in which I have a model named "Content" which inherits from a 3rd party library I've installed as a pip package known as "django-mptt" as shown below. content_viewer/models.py class Content(MPTTModel): content_id =…
nick
  • 439
  • 1
  • 4
  • 17
1
vote
0 answers

django-mptt and bootstrap to create dropdowns

I'm having trouble getting my subcategories to appear in the dropdown using mptt. If I follow the documentation and do something like this: {% load mptt_tags %}
    {% recursetree categories %}
  • {{ node.name }} …
Mike1982
  • 439
  • 10
  • 26
1
vote
1 answer

django-mptt: How to auto select children in admin when selecting parent?

I have some troubles when selecting parent - children are not auto selected. For example when I select Cluster #2 its children (Store #1 and Store #2) are not being selected: How can I fix that? It's important because I need to create many-to-many…
1
vote
0 answers

Django MPTT how to remove indentation from html template

I am using django MPTT model in my template and just want to remove indentation. Now it's look like this: how to remove indentation from html template? here is my html: {% load mptt_tags %} {% recursetree contact…
boyenec
  • 1,405
  • 5
  • 29
1
vote
1 answer

AttributeError at / 'dict' object has no attribute '_mptt_meta'

I try to build blog by using posts and MPTT comments, this will be in the home view www.mysite.com that's mean I cann't pass pk to the url so I tried to get the post objects using for loop comma = Post.objects.all() comm = [] for post in…
Ahmed
  • 280
  • 1
  • 12
1
vote
1 answer

django-mptt count items in add_related_count?

How to add filter(is_public=True) to Question? Category.objects.add_related_count( Category.objects.filter(is_public=True), Question, 'category', 'question_counts', cumulative=True)
Stanislav
  • 59
  • 2
  • 7
1
vote
0 answers

How to create breadcrumb in my view function BY mptt

How to create breadcrumb in my view function? class Category(MPTTModel): name = models.CharField(max_length=50, unique=True) parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') slug =…
Ahmed Az
  • 11
  • 1
  • 2
1
vote
1 answer

Using Django-MPTT in Django-Filters to get children on filtering parent node

I have an MPTT model class, and want to use it in Django-Filter. My MPTT model is; class ProdCategory(MPTTModel): name = models.CharField(max_length=200, unique=True) parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True,…
chhibbz
  • 462
  • 8
  • 30
1
vote
1 answer

Large nested hierarchy in Django / Wagtail: parenting or categorizing?

I have a database containing metadata on 50,000 drugs (medications), which are ordered hierarchically (the taxonomy is called ATC). Example with a heart medication follows: A -- A10 ---- A10X, Metoprolol Some drugs have 4 levels. I need to…
LauperEd
  • 25
  • 3
1
vote
1 answer

Sorting email threads in django using mail header information

I have a django app that stores email threads. When I parse the original emails from an mbox and insert them into the database I include the email header parameters 'message-id' and 'in-reply-to'. The message-id is a unique string that identifies…
ajt
  • 1,341
  • 3
  • 13
  • 30
1
vote
0 answers

Connecting MPTT tree to a model.Model

I am trying to implement a MPTT tree such that Degree (Bachelor,Masters,PhD,Diploma) - Degree_Name (B.tech,B.A,.....M.tech....) --Course_Specialization (Civil,Mechanical,...........Eng,.....etc..) and I have a model class Entity(models.Model): …
Jack
  • 222
  • 2
  • 12
1
vote
1 answer

Serializing MPTT Tree with Django REST Framework

I searched for a similar question without success.. So, i am working on a website in which i am using django-mptt to organize categories. My Model looks like: class Category(MPTTModel): parent = TreeForeignKey('self', on_delete=models.CASCADE,…
Asma Ben
  • 11
  • 2
1
vote
1 answer

Writing an efficient node.all_siblings_leaf() method for django-mptt

I have a tagging system, where the tags exist in a hierarchy. I've used django-mptt to build the Tag model. I want to display a group of tags differently if every sibling in the group is a leaf node. To do this, I want a model method called…
japhyr
  • 1,710
  • 2
  • 18
  • 24
1
vote
1 answer

Porting and existing nested set hierarchy

I have a nested set category table developed with the PHP ORM Doctrine and I would like to port it to a Django app. I started porting it to django-treebeard, but I am having difficulties and I am not sure it can work. The original table had the…
jphilip
  • 136
  • 2
  • 9