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
3 answers

django-mptt fields showing up twice, breaking SQL

I'm using django-mptt to manage a simple CMS, with a model called Page, which looks like this (most presumably irrelevant fields removed): class Page(mptt.Model, BaseModel): title = models.CharField(max_length = 20) slug =…
Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212
0
votes
1 answer

is_deleted for nodes with Django MPTT

I use Django MPTT. I wont delete my nodes but instead I am updating a field is_deleted and filtering the nodes so 'deleted' nodes wont show up. The problem arises if a node is 'deleted' but some of it's descendants is not deleted. The descendants of…
Jamgreen
  • 10,329
  • 29
  • 113
  • 224
0
votes
1 answer

Get parent id in django-mptt

I am using django-mptt and jquery-treetable. I am printing my objects with: {% for node in nodes %} {% endfor %}
{{ node }}
In jquery-treetable the element should have some attributes to…
Jamgreen
  • 10,329
  • 29
  • 113
  • 224
0
votes
1 answer

Django mptt join/merge models

I have this two models: class Folder(MPTTModel): name = models.CharField(max_length=20) description = models.CharField(max_length=200, null=True, blank=True) parent = TreeForeignKey('self', null=True, blank=True,…
0
votes
1 answer

Django mptt throwing error when order insertion value is changed

I have this mptt model: class Program_requirement_category(MPTTModel): display_order = models.IntegerField(null=True, blank=True) name = models.CharField(max_length=100, unique=False) min_credit = models.IntegerField(null=True,…
Abhishek
  • 2,998
  • 9
  • 42
  • 93
0
votes
1 answer

why doesn't this django mptt algorithm correctly compute rank? list index out

I am trying to write a simple algorithm to get the 'rank' of a django mptt model. By 'rank' I mean the number of levels of descendents... similar to MPTTModel.get_level() but counting from leaf to root. My approach is the following: views.py def…
David J.
  • 1,753
  • 13
  • 47
  • 96
0
votes
1 answer

Creating mptt from a django model

I have a django model as follows: (it has both the mptt and the regular model) from django.db import models from mptt.models import MPTTModel, TreeForeignKey class deg_course_cat(models.Model): degree_code = models.CharField(max_length=24) …
Abhishek
  • 2,998
  • 9
  • 42
  • 93
0
votes
1 answer

Django mptt tutorial error

I was following this tutorial and i got stuck. I have defined everything as mentioned in the tutorial but i am getting the following error: NameError at /genres/ global name 'Genre' is not defined Request Method: GET Request URL: …
Abhishek
  • 2,998
  • 9
  • 42
  • 93
0
votes
1 answer

Using django-mptt with django auth_user

I am trying to create a user tree using django-mptt. I have auth_user table and a one-to-one mapping table UserProperties which has a foreign key of auth_user. I added TreeForeignKey of django-mptt in UserProperties model(parent column) on User…
Anuj
  • 1,160
  • 2
  • 20
  • 40
0
votes
1 answer

django-cms placeholder outside cms - how to get related model using the placeholder from the one model that is connected?

I have written the following cms plugin. With this a user can add a connection from one news entry to a project. cms_plugins.py: from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool class…
welworx
  • 370
  • 2
  • 14
0
votes
1 answer

IntegrityError in django mptt - column not unique

I'm having trouble saving a form in a Django app. I want to create an model called 'dataset' from another model called 'image', both of which are mptt models. models class Image(MPTTModel): name = models.CharField(max_length=50, unique=True) …
David J.
  • 1,753
  • 13
  • 47
  • 96
0
votes
2 answers

AttributeError when saving MPTTModel

I'm trying to build a menu app in Django using django-mptt to create nested menu items. The menu items should be ordered by menu_order when the tree is built. The problem is that whenever I add nested menu items, reorder them and save the menu, this…
JLinden
  • 98
  • 12
0
votes
0 answers

django-mptt order_insertion_by and tree rebuild

I started using 'order_insertion_by' to change the default ordering in django-mptt. So far I haven't found issues on my local, but my tests fail. Background: I have test fixture which creates about 10 objects in tree structure and two trees. I…
chhantyal
  • 11,874
  • 7
  • 51
  • 77
0
votes
1 answer

Why do model mixins break django-mptt foreign keys?

I'm modifying a third-party Django app based on django-mptt. I'm trying to refactor one monstrously big model into a base class and a set of mixins. All seemed well, however... class ModelMixin([see below]): class Meta: abstract =…
avramov
  • 2,119
  • 2
  • 18
  • 41
0
votes
1 answer

How to add custom data to Django MPTT model for recursetree template tag

This question about MPTT objects and usage of the {% recursetree %} template tag is related to this one. My Django Model: from mptt.models import MPTTModel, TreeForeignKey class myModel(MPTTModel): myIntA = models.IntegerField(default=0) …
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272