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

How to fix no of child to parent in django-mptt?

I'm want to fix 2 children for each parent. Models.py class CoachingRegistration(MPTTModel): uid = models.UUIDField(unique=True, editable=False, default=uuid.uuid4) placement_id = models.CharField(max_length=13) parent =…
2
votes
1 answer

Queryset ordering for nested objects

I need to build a simple nested comment system in my project with REST API. There are some requirements: The page should contain the pagination of all comments, not just the parent ones. So, if there are 1 comment and 20 nested comments from other…
2
votes
1 answer

django import-export not working with mptt

I'm having and issue trying to get import-export to work for mptt models. This is my code: models.py from django.db import models from mptt.models import MPTTModel, TreeForeignKey class MyModel(MPTTModel): name =…
2
votes
1 answer

How can I annotate a django-mptt TreeQuerySet from aggregate values of children?

Suppose I have the following django-mptt tree: Root node Node 1 Node 2 Node 3 Node 3.1 Node 3.2 ... Every node has the same fields with numerical values (e.g. area, value etc). Can I use a TreeQuerySet to aggregate values (Sum, Count, Avg…
TheVRChris
  • 171
  • 7
2
votes
1 answer

How to apply css to a three level recursive mptt tree in Django template?

I have following template for an Django-mptt tree: {% load static i18n %}
{% load mptt_tags %}
    {% recursetree piece_tree %}
  1. {{ node.name_w_version }}
H C
  • 1,138
  • 4
  • 21
  • 39
2
votes
1 answer

django-mptt ImportError

I have installed django-mptt and have followed the documentation regarding setting up a Django model for MPTT However, I am getting the following ImportError: from mptt.models import MPTTModel, TreeForeignKey ImportError: cannot import name…
Dan
  • 3,041
  • 2
  • 17
  • 9
2
votes
1 answer

Is it possible to use django-mptt and GenericForeignKey?

The model I'm using at the moment essentially has three classes. A root class, a tree attached to the root class and a leaf node class that can be attached anywhere in the tree. e.g. Shop/Category/Product or Shop/Category/Category/Product Product…
Calum
  • 41
  • 1
2
votes
1 answer

Ordering django-mptt foreign key in admin not working

Am using django-mptt to create a Categories model and then using that as a foreign key for a Documents model. The Categories admin works fine and categories are displayed in tree order as expected. However I have two problems with ordering for the…
PhoebeB
  • 8,434
  • 8
  • 57
  • 76
2
votes
0 answers

Django-mptt display hierarchy as table

I am trying to display a hierarchical table as a normal table. model.py class Dimension_value(MPTTModel): name = models.CharField(max_length = 200, null=True, blank = True, default = '') parent = TreeForeignKey("self",…
JeePee
  • 107
  • 1
  • 12
2
votes
0 answers

How to validate and create related objects together with forms

I am trying to validate a related object (ForeignKey) when creating an object the base object with forms. The related object may or may not exist. Below I use MPTT but this is a general foreign key problem. I have a model like this: # model: class…
Greg Samson
  • 1,267
  • 2
  • 11
  • 21
2
votes
0 answers

How do i put the django-mptt in nested dropdown

Hello guys I am really thinking hard on this one I need help. How do I put the django-mptt in a nested dropdown. the recursetree tag when I put it in a bootstrap dropdown it comes out all jumbled up. {% load mptt_tags %}
2
votes
0 answers

How to save in database new order of nodes in tree with ajax | django?

I use django-mptt application in backend and jsTree plugin in frontend to create such tree as in the picture below in my Django project: jsTree plugin allows you to drag and drop nodes inside tree. django-mptt application by default in DB create…
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
2
votes
1 answer

child node is treated as grand child node when trying to structure

I am using django-mptt library for the category. I could show the list of categories in template but I wanted to indent it properly so user can know which is a main category and which one is sub-category and etc. The way i tried to structure is {%…
Serenity
  • 3,884
  • 6
  • 44
  • 87
2
votes
0 answers

Tree with checkboxes | DJANGO

I have model Program with ManyToManyField function. I need too create form where as in the picture below where users can select and add functions to program. In other words I need TreeView with checkbox. How create such widget? I found django-mptt…
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193
2
votes
2 answers

django-parler doesn't show tabs in admin

For some reason I'm not seeing any language tabs when adding to the admin. I'm using Django 1.9.10. I was using django-hvad but decided to try parler. I have tried the same exact code in a fresh project and it worked but in my existing project it…