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
0
votes
1 answer

What went wrong with my django-mptt tree?

I'm using django-mptt 0.4.2 and have trouble with one of my data trees. Here is the tree as seen in mysql; mysql> select id, lft,rght,level from my_object where tree_id=30613; +-------+-----+------+-------+ | id | lft | rght | level…
Hobhouse
  • 15,463
  • 12
  • 35
  • 43
0
votes
1 answer

Problem with get_children() method when using TreeManager. Wrong result

I have encountered an strange problem with the use of TreeManager Here is my code: # other imports from mptt.models import MPTTModel, TreeForeignKey from mptt.managers import TreeManager class SectionManager(TreeManager): def…
jcuot
  • 935
  • 9
  • 24
0
votes
1 answer

How should I structure a tree of multiple model types?

I'm trying to model television shows down to the episode level. Given that each level of the tree (network, series, season, episode) has different fields, I want to use different model types for each level. My initial approach was to keep track of…
John Tacos
  • 167
  • 4
0
votes
1 answer

django-mptt's MPTTModel inheritance issue

Met unexpected behaviour with model inheritance. I launch this code in django shell: import mptt from django.db import models class MyTreeQuerySet(mptt.querysets.TreeQuerySet): pass class MyTreeManager( …
0
votes
1 answer

Django: Many2Many Relationship During Pre_Save Signal?

Let's assume we have the following class: Class 'Config' class Config(models.Model): name = models.CharField(max_length=40, editable=True, blank=False, null=False) nodes = models.ManyToManyField(HierarchyNode_MPTT) element =…
DevKing
  • 211
  • 5
  • 14
0
votes
1 answer

SQL query on Many to Many with intersection

I am working with django-categories which uses django-mptt under the hood. (That implicates db structure that I am using.) I have some products: product -------- id | name 1 | Apple 2 | Orange 3 | Tomato …
d21d3q
  • 365
  • 2
  • 10
0
votes
1 answer

django-MPTT drilldown template

I am having some trouble getting a drilldown for mptt in my template. I have the following model. models.py class Dimension_value(MPTTModel): name = models.CharField(max_length = 200, null=True, blank = True, default = '') parent =…
JeePee
  • 107
  • 1
  • 12
0
votes
1 answer

AttributeError: 'User' object has no attribute 'get_descendant_count' | django-mptt

Can someone help me to fix next problem. I use django-mptt application in my Django project. I want to make tree of related users. For this task I decided to create Profile model with next code. from mptt.models import MPTTModel,…
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
0
votes
0 answers

Adjusted local models, getting columns do not exist in production environment

I have a django blog project via PythonAnywhere using PostGres, and have recently tried to push my changes (mainly implementing Django-MPTT) to my models to my production server via git. I have ran migrations etc, but when I load the site, I got a…
ML_Engine
  • 1,065
  • 2
  • 13
  • 31
0
votes
3 answers

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

I would like my categories to show all items in that category including descendant categories, so the parent category contains all items for subcategories. I have tried adding this method to my Category class in models.py def…
0
votes
1 answer

django admin nested inlines with mptt children

I'm trying to figure out if it's possible to create a ModelAdmin with multiple nested inlines like: Contract Mainproduct Subproduct1 Subproduct2 SubSubproduct And I'm also trying to solve the models with mptt. My models are looking like…
akephalos
  • 13
  • 3
0
votes
1 answer

Django-mptt different order based on level

I'm trying to make a threaded commenting system based on django-mptt. The problem that I'm having is that the order of the comments cannot be changed according to their level. What I am trying to achieve is a system in which "first level comments"…
0
votes
1 answer

Different models in django-template

I'm very new in Django and couldn't find solution for this. How can I pass 2 querysets from different models in 1 template? I use mptt categories and stack with it for awhile. I know that I have to make something with views.py but how can I combine…
V. Khud
  • 35
  • 1
  • 5
0
votes
1 answer

While trying to post mptt model via django rest framework getting ValueError: Cannot use None as a query value

Here is the view I'm trying to write tests for: class RestaurantsTreeView(generics.ListCreateAPIView): serializer_class = RestarauntsTreeSerializer def get_serializer_class(self): from rest_framework import serializers if…
Vassily
  • 5,263
  • 4
  • 33
  • 63
0
votes
1 answer

Django-mptt admin get child categories

I have next models in my Django project: class Category(MPTTModel): title_of_category = models.CharField(max_length=50, unique=True, verbose_name='Subcategory', default='') parent = TreeForeignKey('self', null=True, blank=True,…
Just Snake
  • 541
  • 2
  • 6
  • 10