Questions tagged [mptt]

mptt refers to "Modified Preorder Tree Traversal" algorithm for storing hierarchical data

mptt refers to "Modified Preorder Tree Traversal" algorithm for storing hierarchical data.

See also:

146 questions
1
vote
1 answer

Sort MPTT resultset into a multidimensional array PHP

I have been experimenting with the Modified Pre-Order Tree Traversal Pattern, my test case code is returning the results as expected however I am having trouble converting the 2D array into a multi-dimensional array to present it. Here is an example…
user126918
0
votes
1 answer

MPTT - How can I pass extra data for each node to the template?

Given the following view: def comments(request): comments_list = Thing.objects.filter(thing_type=2) #Thing model extends MPTTModel comments_extra_data_list = Data.objects.filter(thing__in=comments_list) #Data objects have data for…
bentzy
  • 301
  • 2
  • 4
  • 15
0
votes
1 answer

django-mptt : Filter all categories having an online entry

I am passing this Django Blog App category system to django-mptt. The problem I have is about the _get_online_category method. This method allows me to get only the category having an Entry. def _get_online_categories(self): """ Returns…
Natim
  • 17,274
  • 23
  • 92
  • 150
0
votes
0 answers

Django threaded / nested comments

What's the best way to implement threaded/nested comments in Django? I've read a bit about MPTT and django-threadedcomments but all the posts seem to be from years ago. Is using MPTT still the 'accepted' way or is there a newer way to do it?
Callum
  • 195
  • 2
  • 22
0
votes
0 answers

Django-MPTT using Parent and Child in same form

My goal is straightforward: I want to enable the selection of a parent category first and then choose its corresponding child categories. Unfortunately, I am encountering difficulties in implementing this functionality. My code is
0
votes
0 answers

"Node" is unknown import symbol

I installed mptt and created some categories and sub categories. Now I want to control under admin page admin.py from django.contrib import admin from zummit.models import Product from zummit.models import ProductImage from mptt.admin import…
0
votes
1 answer

Django MPTT get descendants subquery

I am trying to get the same queryset I would get if I used get_queryset_descendants(queryset, include_self=True) without losing the queryset (keeping it as a subquery). Because of how get_queryset_descendants works, the queryset is being resolved…
Tenshiro
  • 1
  • 4
0
votes
1 answer

Django MPTT, can't get parent_id for threaded comments reply

My Problems are as follows: Im relatively new to Django. so sorry for this mess. I've tried to implement threaded comments to my blog via MPTT. But when i pressing the 'Reply' Button django throws me a Type Error Normal parent comments working…
Cone16
  • 1
  • 1
0
votes
0 answers

mptt not linking children and parent - Django

I'm having an issue that I seriously can't wrap my head around. I am using Django MPTT models and evrerything seems to be working fine (i.e. I can run the migrations and insert data in the database), but for some reason the TreeForeignKey table…
ETisREAL
  • 90
  • 1
  • 2
  • 9
0
votes
1 answer

Django mptt returns -2 on get_descendant_count()

I am trying to get the descendants of a root node, but for some reason the function returns -2 on get_descendant_count(). Here's the code: roots = Project.tree.root_nodes() print(roots[0].get_descendants()) // returns…
mgPePe
  • 5,677
  • 12
  • 52
  • 85
0
votes
1 answer

Issue With Nested Comments Using MPTT in Django and Django Rest Framework API - Result In Detail Not Found

I'm trying to create a nested comment system using MPTT but using Django Rest Framework to serialize MPTT tree. I got the nested comments to work - and these comments are added, edited, and deleted by calling Django Rest Framework API endpoints…
0
votes
0 answers

The problem with duplicate nodes in sqlalchemy mptt

On our project, with numerous requests to api in a short time, they are processed in different threads. When a user requests the creation of several instances at once in a table that is inherited from MPTT, this occurs in such a way that the…
savao
  • 103
  • 7
0
votes
0 answers

Bulk import with mptt, django and csv

I have the following code to take data from a very large csv, import it into a Django model and convert it into nested categories (mptt model). with open(path, "rt") as f: reader = csv.reader(f, dialect="excel") next(reader) …
megler
  • 217
  • 1
  • 2
  • 9
0
votes
0 answers

MPTT Django how to get children with user_id = some_user_id. NOT ALL children

def get_queryset(self): if not self.request.user.is_authenticated: # for swagger generation only return CannedAnswer.objects.none() if self.action in ['list']: return CannedAnswer.objects.filter( …
ohmywollie
  • 47
  • 3
0
votes
1 answer

Extending Django FlatPages to use MPTT

Preface: I was writing my own Page app that used MPTT and a custom page model. This was working for me, but FlatPages is more refined than my custom Page Model and so I'm leaning toward just extending it. from django.db import models from…
Francis Yaconiello
  • 10,829
  • 2
  • 35
  • 54