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
1
vote
1 answer

MPTT model creation fails in data migration

I have written a data migration file for creating some initial data for a MPTT model. But the creation fails, def create_foo(apps, schema_editor): db_alias = schema_editor.connection.alias logger = logging.getLogger(__name__) Foo =…
1
vote
0 answers

Group queryset by attribute value

class Customer(models.Model): ... class Order(models.Model): customer = models.ForeignKey(Customer) def __unicode__(self): return ">> Order.objects.all() [
Bea Trix
  • 75
  • 1
  • 7
1
vote
1 answer

django_mptt model with post_save signal

class Category(MPTTModel): name = models.CharField(max_length=256) parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True) class MPTTMeta: order_insertion_by =…
madzohan
  • 11,488
  • 9
  • 40
  • 67
1
vote
2 answers

Extending django User model using Django-mppt

I have a hierarchical structure in the sense that there can be a Company and a User, where a company can be nested within another company while users can be independent or belong to a company. Is there any documentation on how to use the django user…
Muniu
  • 187
  • 1
  • 2
  • 15
1
vote
0 answers

Represent object hierarchy in the related model with django-mptt

I have two models, see below. How can I represent page attribute as a tree in my CardWidget form? I.e. I want it to be rendered the same way as it happens in my Page form, it should be a properly indented tree. models.py class Page(MPTTModel): …
Michael Samoylov
  • 2,933
  • 3
  • 25
  • 33
1
vote
1 answer

How do I activate/use django-mptt on an database with data?

I have an existing database with an offices table. It has the following fields: id lvl parent_id name code I have a Django (1.7) model that looks like: class Office(models.Model): id = models.IntegerField( primary_key=True ) lvl …
Clay
  • 2,949
  • 3
  • 38
  • 54
1
vote
1 answer

Getting django-mptt to play nice with django-reversion

I'm working on a project that is using django-reversion to track changes and give the ability to revert to earlier states, and django-mptt for some tree-shaped models. The delete and revert functionality, however, have some funky behavior. I'm…
MBrizzle
  • 1,783
  • 1
  • 18
  • 31
1
vote
0 answers

Django 1.6 admin .preserve_filters not working with MPTT 0.6 admin.MPTTModelAdmin

All, I have a django 1.6 admin page and I would like to use MPTT but whenever I use mptt.admin.MPTTModelAdmin, preserve_filters no longer works. If I use the standard django ModelAdmin, then preserve_filters works great. Any ideas why the…
Brian
  • 11
  • 1
1
vote
0 answers

How to control join conditionals in Django query? Or how to filter a query based on values of django-mptt ancestor fields?

I'm using django-mppt to allow Project models to have parent Projects in my application (and Tasks belong to Projects). Each Project has a status, and I'm trying to query for all Projects which are active and whose ancestors are all active as well…
balleyne
  • 318
  • 1
  • 3
  • 8
1
vote
1 answer

django-mptt multiple trees and queryset

My model Class can contain multiple trees. class MyClass(MPTTModel, AbstractClass): """ """ name = models.CharField(_('name'), max_length=255) parent = TreeForeignKey('self', null=True, blank=True, related_name='children') *** I…
Daviddd
  • 761
  • 2
  • 12
  • 37
1
vote
0 answers

django-mptt setup: can't create table / syncdb

I'm following the django-mptt tutorial here: http://django-mptt.github.io/django-mptt/tutorial.html#getting-started I pip install'd django-mptt and then placed the directory (renamed mttp) in the same folder level as my app organizations. Top level…
Amy Lam
  • 169
  • 1
  • 1
  • 13
1
vote
1 answer

Django model and mptt integration

I have a django model like the following: from django.db import models from mptt.models import MPTTModel, TreeForeignKey class deg_course_cat(models.Model): degree_code = models.CharField(max_length=24) specialization =…
Abhishek
  • 2,998
  • 9
  • 42
  • 93
1
vote
0 answers

MTPP and MTTPAdmin. Admin view

I need to use categories in django server, and I am currently using mptt and mptt-admin. That is what I am trying to do: #### models.py #### class File(MPTTModel) name = models.CharField(max_length=20) description =…
Andrew
  • 161
  • 2
  • 14
1
vote
1 answer

  instead of
  • in {% recursetree nodes %}
  • I have this working:
      {% recursetree nodes %}
    • {{ node.name }} {% if not node.is_leaf_node %}
        {{ children }}
    Adam
    • 2,948
    • 10
    • 43
    • 74
    1
    vote
    0 answers

    django and postgres: sqlclear always fails to delete constraint

    django 1.6 with postgres 9.1 When trying to re-init a db I typically use the management command sqlclear so I can target tables specific to an app. In django 1.6 and postgres, whenever I use this command, it will always fail when it attempts to…
    w--
    • 6,427
    • 12
    • 54
    • 92