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 display child element in Django MPTT?

I am trying to call parent and child element of a model, I have gone through the MPTT model documentation. I did as mentioned on the documentation, but my template is failing to print children What can be the possible cause of this problem? Here is…
Madhav Dhungana
  • 476
  • 4
  • 13
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
0
votes
1 answer

django-mptt tree model returns empty children in template using recursetree

I am using Django 3.2 and django-mppt 0.13.4 This is my (simplified) model: /path/to/myapp/models.py class Comment(MPTTModel, MyTimestampedModel): parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, …
Homunculus Reticulli
  • 65,167
  • 81
  • 216
  • 341
0
votes
1 answer

Is it possible to rebuild a single tree?

I can only find documentation for Model.objects.rebuild() which rebuilds all trees. What if I wanted to rebuild a single tree? Is that possible? If it's not possible - does that mean using move_node or insert_node results in rebuilding for all…
Chris
  • 500
  • 6
  • 25
0
votes
1 answer

What are the current ways to get_absolute_url for django-mptt?

I read other questions, but I didn't find anything useful for Django 3, they just don't work. The link type is needed like this: post/categories/subcategories/**etc I think an adequate answer will be useful for everyone. Tell me how to do it for…
Razilator
  • 75
  • 5
0
votes
1 answer

Django Jazzmin add button disappeared after adding mptt admin

I'm using jazzmin for django admin and mptt. After adding mptt to admin, in jazzmin theme add button disappeared. I'm using latest versions of all libraries class CustomMPTTModelAdmin(MPTTModelAdmin): # specify pixel amount for this ModelAdmin…
0
votes
1 answer

django-moderation with custom model managers

I am using Django 3.2 and django-moderation. I want to moderate Foo: class MyCustomManager1(models.Manager): def get_queryset(self): return super().get_queryset().filter(is_published=True) class MyCustomManager2(MyCustomManager1): …
Homunculus Reticulli
  • 65,167
  • 81
  • 216
  • 341
0
votes
1 answer

How to get parent node name while using django mptt package in django rest serializers?

I am only getting parent id with this code, but i need parent node name . Is it possible to get parent node name ? class Department(MPTTModel,NameStatusModelMixin): desc = models.TextField(blank=True, null=True, default=None) slug =…
user15883648
0
votes
1 answer

ValueError: The view videos.views.add_comment_post didn't return an HttpResponse object. It returned None instead in Django

I tried to add comments with the post and it raise this error, and I supmit my comment using ajax but it seems the problem coming from the view but I couldn't figure out what exactly the problem My add comments View @login_required def…
Ahmed
  • 280
  • 1
  • 12
0
votes
1 answer

Django doesn't recognize/can't find post_save edited field?

I'm trying to create a unique SlugField using a post_save model signal. If the SlugField already exists, a number should be appended to the slug to make it unique. However, Django does not seem to to recognize when the SlugField already exists. I'm…
Chris
  • 500
  • 6
  • 25
0
votes
1 answer

Why are all my SQL queries being duplicated 4 times for Django using "Prefetch_related" for nested MPTT children?

I have a Child MPTT model that has a ForeignKey to itself: class Child(MPTTModel): title = models.CharField(max_length=255) parent = TreeForeignKey( "self", on_delete=models.CASCADE, null=True, blank=True, related_name="children" …
Chris
  • 500
  • 6
  • 25
0
votes
1 answer

ascending=True not working in django-mptt

Hi good day I'm currently following Django-MPTT documentation and I have a problem using ascending=True. Here's my code: views.py def show_genres(request): Try01 = Genre.objects.filter(name="Rock") context = {'genres': Genre.objects.all(),…
miss rain
  • 15
  • 6
0
votes
1 answer

How to limit the max deep of recursetree in Django mttp?

I'm using django-mttp. How can I limit the max depth of recursetree? Max=3 Model: class Comment(MPTTModel): """评论表""" nid = models.AutoField(primary_key=True) news = models.ForeignKey( verbose_name="评论文章", to="News", …
William
  • 3,724
  • 9
  • 43
  • 76
0
votes
1 answer

Django mptt, can I delete the default 'name' filed?

I'm following the django-mptt tutorial,and there is a 'name' filed: class Genre(MPTTModel): name = models.CharField(max_length=50, unique=True) parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True,…
William
  • 3,724
  • 9
  • 43
  • 76
0
votes
0 answers

Django mptt rendering item associated to parent category and sub category

I am building a django app for pathology/laboratory reporting system. I need a form that will take value for different tests like (HIV-negative, some test-10). Since there are 100 and 1000 of tests and these test are grouped by categories like…
Pushpan
  • 81
  • 1
  • 2
  • 8