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

How to create a Django MPTT model with multiple trees

I am trying to create a structure where I have one model named "Company" and another model named "FSLI". The FSLI is an MPTT model. Each FSLI must be mapped to a Company. Each Company can have multiple FSLIs. Following is my code for FSLI…
0
votes
1 answer

Django mptt model not linking to parent

Hello I am in the process of implementing a hierarchical location model. I have also created a form to be able to add locations while not using the admin interface. Tp do this I am using mptt's TreeNoeChoiceField. However when I select the correct…
callison98
  • 11
  • 1
0
votes
1 answer

Django-MPTT Template: Subcategories not rendered when in recursetree

I am building a category and subcategory tree for my eCommerce website. Category model has a TreeForeignKey to itself so that categories can have many other subcategories as children. In my product.html route, I successfully rendered the categories…
0
votes
0 answers

Django mptt - how to show full name

is there any option to show full name in Django mptt? For example, I have model: class RecipeCategory(MPTTModel): title = models.CharField(max_length=255, verbose_name='Nazwa kategorii') full_name = models.CharField(max_length=255,…
0
votes
1 answer

Django Mptt : How to nest another Model

I have two Models, reseller and customer. I can generate Tree hierarchy for reseller, But I want to list down Customers under their immediate parent reseller. models.py from django.db import models from mptt.models import MPTTModel,…
sangramz
  • 3
  • 5
0
votes
1 answer

Could not find the variable, namely could not find the key "VariableDoesNotExist at /genres/"

I can not get the objects on the template that are associated with the mptt django model. Failed lookup for key [genres]. I have a model that is linked to another model. I use mptt django so that the object is connected through the relationship of…
Echo Foe
  • 398
  • 1
  • 2
  • 16
0
votes
2 answers

Correct way to delete all MpttModel Entries using Django Manager

I have a Django model(Feature) sub-classing MPTTModel. As best practice for MPTT model for foreign key is to keep on_delete=PROTECT, struggling to delete all MPTT entries at once, using Feature.objects.all().delete() I get following error…
S.K
  • 480
  • 1
  • 4
  • 19
0
votes
1 answer

Django mptt recursetree with get_cached_trees in template

In View: context['categories'] = = models.Category.objects.all().get_cached_trees() In template: {% load mptt_tags %}
    {% recursetree categories %}
  • {{ node.name }} {% if not node.is_leaf_node %} …
dreamstack
  • 13
  • 3
0
votes
2 answers

What are non-scriptable objects in Django?

I have the following model: class Performance(Event): date_created = models.DateTimeField(_('date created'), default=timezone.now) date_modified = models.DateTimeField(_('date_modified'), auto_now=True) class PerformanceWork(models.Model): …
H C
  • 1,138
  • 4
  • 21
  • 39
0
votes
1 answer

How to include dropdown menu with django-mptt in template

I want to be able to create dropdown menu using admin panel. At this moment in model I can choose if subpage is children of another and in what order it should be displayed. But I don't know how to implement all of this together in template. Can…
0
votes
1 answer

Django mptt get_cached_trees() hits database

I am using get_cached_trees() method from django mptt library As in the docs: Takes a list/queryset of model objects in MPTT left (depth-first) order and caches the children and parent on each node. This allows up and down traversal through the…
techkuz
  • 3,608
  • 5
  • 34
  • 62
0
votes
1 answer

Django MPTT order_by error

models.py class Category(MPTTModel): name = models.CharField(max_length=100) slug = models.SlugField(max_length=200, unique=True) parent = models.ForeignKey('self', blank=True, null=True, related_name='child') image =…
pkdkk
  • 3,905
  • 8
  • 44
  • 69
0
votes
1 answer

Custom Chainable QuerySet

This is a piece of my code from django.db import models from django.db.models.query import QuerySet from mptt.models import MPTTModel from base.models import Content, OrderedContent class ArgumentQuerySet(QuerySet): def…
0
votes
1 answer

After migration data is not saving correctly

I am using latest version of django, django-mptt. Here is the model in previous state: shop_options = ( ('grocery', _('Grocery')), ('medicine', _('Medicine')), ('electronics', _('Electronics')), ('fashion', _('Fashion')), …
pyprism
  • 2,928
  • 10
  • 46
  • 85
0
votes
1 answer

django-mptt different data ordering on two machines with same code and data

I'm using django-mptt library for creating directory hierarchy like this: directory_a directory_some_name directory_a directory_b directory_some_name directory_b directory_some_name directory_some_name models.py class…
Max
  • 1,634
  • 1
  • 19
  • 36