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

Django MPTT - tree filtering

I am using MPTT's templatetag to render my genre tree. {% for genre, structure in genres|tree_info %} {% if tree.new_level %}
  • {% else %}
  • {% endif %} {{ genre.name }} {% for level in tree.closed_levels…
ohnoes
  • 5,542
  • 6
  • 34
  • 32
1
vote
1 answer

Which module to manage nodes in multiple tree?

I am creating a web tool to manage bills of materials (BOM). I managed to get some nice presentation of BOMs using django with js-tree but now I would like to put all of this in a database. My trees look like this: - Root Part (ie Product A) -…
Romn
  • 174
  • 2
  • 14
1
vote
0 answers

Improving performance of an Django MPTT tree

I have implemented the follow model to capture the structure of a classical piece of music. I'm using the MPTT to implement movements, opera acts and arias. model.py: TreeForeignKey(Work, blank=True, null=True, db_index=True,…
H C
  • 1,138
  • 4
  • 21
  • 39
1
vote
1 answer

Django MPTT tree as model filter in admin

I have a model linked to a related model that is a Django MPTT tree model, I would like to be able to filter the first model using the Django MPTT tree in the admin console. class Tenders(models.Model): ... sector=models.ForeignKey(Sector,…
1
vote
0 answers

how return parent products , RecursiveField in rest api?

I don't have return parent in products rest api django. when i request sub-categories in url show parent recursive ,but when i request products in url parent field is empty. please help me, thanks. serializers.py : i have used RecursiveField. from…
omides248
  • 128
  • 2
  • 12
1
vote
1 answer

Use django-mptt to query the database for all root categories that have at least one subcategory and at least one product

I have a Category model and I use django-mptt to have subcategories (and sub-subcategories, etc.). I also have products, which are assigned to categories. I want to query the database for all root categories that have at least one subcategory and at…
Nick
  • 8,049
  • 18
  • 63
  • 107
1
vote
1 answer

Django MPTT: Rebuild tree in migrations file

I already have a model in my project that I now want to use with django-mptt. This model already has some data in it. During migrations, you are asked to set default values for some of the fields django-mptt creates. As directed in the…
Navid Khan
  • 979
  • 11
  • 24
1
vote
1 answer

django-mptt serialization return children nodes outside of parent node also

I am using django-mptt with django-rest-framework and for recursive serialization I am using djangorestframework-recursive package but it returns child node outside of parent node also. I have tried to_representation() also that leads to same…
1
vote
1 answer

copy values of multiple ModelMutipleChoiceField into one after Post using MPTT

I've been struggling with this issue all day and hope someone can help. I have all my hierarchies classified by category in the same table. during the form creation, I want to separate each hierarchy by category and render it using a…
1
vote
2 answers

What is the correct way to delete a child node in django-mptt tree structure

I am using Django: >>> django.VERSION (1, 11, 15, u'final', 0) MPTT: django-mptt 0.9.1 In Models: from mptt.models import MPTTModel, TreeForeignKey class Location(MPTTModel): id = models.AutoField(primary_key=True) name …
Areebah
  • 43
  • 8
1
vote
1 answer

How do I use django mptt?

I have a model: class Company(models.Model): name = models.CharField( max_length=100) parent = models.ForeignKey('self', null=True, blank=True, related_name='children') mptt.register(Company, order_insertion_by=['name']) and class…
amit
1
vote
1 answer

How to know level of every child relative to main parent in django-mptt?

I use django-mptt application in my project. Let me try to explain the problem. views.py: user_profile = Profile.objects.get(user=self.request.user) referrals = user_profile.get_descendants().filter(level__lte=profile.level + 3) With the help of…
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
1
vote
2 answers

Problem using django mptt

I am having problem implementing django mptt. Here is my model: class Company(models.Model): name = models.CharField( max_length=100) parent = models.ForeignKey('self', null=True, blank=True, related_name='children') …
amit
1
vote
1 answer

How to show a certain number of levels in django-mptt?

In my Django project I use django-mptt application to create hierarchical tree. Right now next code works well but I want to show only first 4 level of the tree. How to make it correctly? I am confused. views.py: context['caregories'] =…
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
1
vote
2 answers

AttributeError: 'TreeQuerySet' object has no attribute 'get_family'

I am using django mptt and i want to get all whole family of one child. When i call other functions it works fine For example i filter object and call function get_family p = Platform.objects.filter(name__startswith='signals') s =…
Johnny
  • 59
  • 2
  • 7