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
4
votes
2 answers

Serializing django-mptt trees in Tastypie

How do I serialize django-mptt trees in Tastypie? I want to use django-mptt's cache_tree_children(). I've tried applying in different Tastypie hooks, but it throws an error.
dan-klasson
  • 13,734
  • 14
  • 63
  • 101
4
votes
1 answer

Is MPTT an overkill for maintaining a tree like database even if the depth is around 3 - 4?

I am planning to store some tree like data in MySQL. Topics can have sub topics and they in turn can have more sub topics. Is Modified Preorder Tree Traversal(MPTT) an over kill even if the maximum depth is around 3 - 4?
4
votes
1 answer

ImportError: cannot import name MPTTModel

I did the steps at the tutorial " http://django-mptt.github.com/django-mptt/tutorial.html " but it still give me the import error , I double check the code for the mptt and found the class MPTTMODEL exist in the mptt>model file Validating…
Kareem Hashem
  • 1,057
  • 1
  • 9
  • 25
3
votes
1 answer

Django-mptt TreeManyToManyField not working?

I try for a little while set up django-mptt in my project. I took a sample from tutorial and changed model acordingly which looks like this: class Genre(MPTTModel): pk = models.AutoField(primary_key=True) name = models.CharField(max_length=50,…
delete
  • 55
  • 7
3
votes
2 answers

Determining "last" element for each level in django-mptt

I'm trying to generate a list akin to:
  • Parent 1
    • Child 1
    • Child 2
    • Child 3
  • Parent 2
    • Child…
Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
3
votes
1 answer

mptt tree pagination

I want to make simple pagination of mpttmodel instances. I have this model: class Thing(MPTTModel): text = models.TextField() parent = TreeForeignKey('self', null=True, blank=True, related_name='children') The problem is, when i trying to…
nukl
  • 10,073
  • 15
  • 42
  • 58
3
votes
1 answer

'TreeQuerySet' object has no attribute 'name'

I have a Problem in Converting the' TreeQuerySet' object to the QuerySet object This is the error I am getting While serializing using DRF Got AttributeError when attempting to get a value for field name on serializer SubCategoriesSerializer. The…
Puneeth Reddy
  • 137
  • 2
  • 11
3
votes
1 answer

How to bulk_create using a django-mptt model?

I need to use bulk_create on a django-mptt model, but I am getting an error: django.db.utils.IntegrityError: null value in column "lft" violates not-null constraint DETAIL: Failing row contains (2, Magic, null, null, null, null, null, null,…
Lord Elrond
  • 13,430
  • 7
  • 40
  • 80
3
votes
1 answer

Annotate Total Count of Descents of Mptt Model

Question Given the models below, I want to get a queryset of all pages, annotated with the total number of comments in the thread associated to the page, including all comments in a comment thread tree associated with pages. I am using django-mptt…
gtalarico
  • 4,409
  • 1
  • 20
  • 42
3
votes
0 answers

How can I reduce recursive MPTT tree queries when serializing with DRF

Working on an e-commerce project. Project has related models. Category model has MPTT inheritance. It using Django Rest Framework for communicate between API's. A foreign service recently wants me to put full Category path into XML response on my…
Sencer H.
  • 1,201
  • 1
  • 13
  • 35
3
votes
0 answers

Registering models for translation using django-modeltransltation causes error with MPTTModel

I am using django 2.0.1 with django-modeltranslation 0.12.2 and django-mptt 0.9.0 When I try to register a model for translation that extends MPTTModel I get that error: File "/home/peter/Desktop/dokkanz/listing/urls.py", line 3, in
3
votes
0 answers

django-mptt get full tree from table

I'm using the app django-mptt to store a small tree structure. In django view, how can I query the entire table in a single query, to get a queryset/list with each instance having a children attribute? So I would like to do: groups =…
user3599803
  • 6,435
  • 17
  • 69
  • 130
3
votes
0 answers

How to implement "Drag and Drop" functionality in django-mptt?

I use django-mptt application in my project. This application allows users drag and drop tree nodes in admin page (DraggableMPTTAdmin). Is it possible to make the same functionality in custom template (not in admin)? P.S. I tried to use jsTree…
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
3
votes
1 answer

Combine django mptt TreeNodeChoiceField with django-autocomplete-light ModelSelect2 widget

A django-mptt TreeNodeChoiceField gives indented select options, whereas I can filter my results using django-autocomplete-light. However, the ModelSelect2 widget overwrites the rendered html, which removes the indentation. I would like to combine…
JIN
  • 647
  • 1
  • 7
  • 19
3
votes
1 answer

django-polymorphic-tree serializer

I would like to serialize all the nodes in my PolymorphicMPTTModel with their corresponding fields. Following the documentation django-polymorphic and django-mptt i get this: { "count":1, "next":null, "previous":null, "results":[ …