Hi,
I am having problem implementing django mptt.
Here is my model:
class Company(models.Model):
name = models.CharField( max_length=100)
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
mptt.register(Company, order_insertion_by=['name'])
And
class Financials(models.Model):
...
I have a model:
class Company(models.Model):
name = models.CharField( max_length=100)
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
mptt.register(Company, order_insertion_by=['name'])
and
class Financials(models.Model):
year = models.IntegerField()
revenue = models.DecimalField(ma...
I am using MPTT's templatetag to render my genre tree.
{% for genre, structure in genres|tree_info %}
{% if tree.new_level %}<ul><li>{% else %}</li><li>{% endif %}
{{ genre.name }}
{% for level in tree.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
The thing is, my genre object has is_visible property w...
Imagine that I have an mptt tree of objects and their population like:
Animal, 60
aardvark, 30
bobcat, 20
chipmunk, 10
Vegetable, 6
apple, 1
beet, 2
cauliflower, 3
Mineral 0
How would you sort the above by population on each sublevel? I want to get to:
Animal, 60
aardvark, 30
bobcat, 20
chipmunk, 10
Vegetable, 6
caul...
I'm trying to tie django-mptt and contrib.admin together by providing something friendlier than a flat list in the admin. Because the trees are supposed to be large (otherwise i wouldn't be using nested sets), users should be able to expand and collapse parts of it.
When a user expands or collapses or expands a branch (ajax is used for...
I want to access the latest object a django-mptt tree.
Is it possible to do this from a django template?
...
I'm making a threaded forum app using django-mptt. Everything is up and running, but I have trouble building one specific queryset.
I want to retrieve posts which:
1) are root nodes
2) are posted by current_user or have a descendant posted by current_user.
What I have so far is this:
Post.objects.filter(Q(user = current_user) | Q...
Has anyone managed to get django-mptt working with inherited models? After 3 days am close to giving up!
If you use abstract this doesn't work because the children can only have parents within the subclass.
Tried using normal inheritance and django looks for the parent, lft fields etc. in the child class instead of the parent. Can giv...
In django-mptt full_tree_for_model returns full tree and using drilldown_tree_for_node I can get tree without siblings.
How to include siblings?
lets say i have:
a1
-b1
--c1
-b2
-b3
--c3
I want to generate from a1 node:
a1
-b1
-b2
-b3
from b1:
a1
-b1
--c1
-b2
-b3
from b2:
a1
-b1
-b2
-b3
and so on...
...
I'm attempting to use django-mptt with very little luck. This is with Python2.5, windows, sqlite3, Django 1.2pre , django-mptt latest from svn.
The code:
model:
class Node(models.Model):
name = models.CharField(max_length=20, blank=True)
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
...
I have a category tree, with Items entry related to the category. So this is my model file:
from django.db import models
import mptt
class Category(models.Model):
nombre=models.CharField(max_length=70)
padre=models.ForeignKey('self', blank=True, null=True)
def __unicode__(self):
return self.nombre
class Meta:
ordering = ['tre...
I'm using Ben Firshman's fork of django-MPTT (hat tip to Daniel Roseman for the recommendation).
I've got stuck trying to re-order nodes which share a common parent. I've got a list of primary keys, like this:
ids = [5, 9, 7, 3]
All of these nodes have a parent, say with primary key 1.
At present, these nodes are ordered [5, 3, 9, 7...
I'm looking for a good way to store and use hierarchical (parent/child) data in Django. I've been using django-mptt, but it seems entirely incompatible with my brain - I end up with non-obvious bugs in non-obvious places, mostly when moving things around in the tree: I end up with inconsistent state, where a node and its parent will disa...
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 = AutoSlugField(populate_from = 'title')
contents = models.TextField()
parent = models.ForeignKey('s...
I've been using django-mptt in my project for a while now, it's fabulous. Recently, I've found a need to override a model's save() method that uses mptt, and I'm getting an error when I try to save a new instance of that model:
Exception Type: ValueError at /admin/scrivener/page/add/
Exception Value: Cannot use None as a query value
...
django-mptt seems determined to drive me out of my mind. I'm trying to do something relatively simple: I'm going to delete a node, and need to do something reasonable with the node's children. Namely, I'd like to move them up one level so they're children of their current parent's parent.
That is, if the tree looks like:
Root
|
Gran...
From the homepage of django-mptt
Version 0.2.1 is not compatible with Django 1.0 and above - please use SVN trunk for now
I tend to avoid using trunk for work that is going live any time soon, But I have a rush job.
Does it work with Django 1.2, (beyond "hello world" equivalents) Does anyone have any current experience / odd bugs ...
How do you deal with hierarchical URLs in Django? Any best practices for that?
Eg. If I would have an URL like /blog/category1/category2/myblogentry (using eg. django-mptt), would you do some checking before in urls.py or give the whole path to a view, let it check every part if it is a valid category etc?
Doesn't sound so tough, but ju...
I'm spitting out my categories tree like so:
<div id="categories-tree">
{% load mptt_tags %}
{% full_tree_for_model bugs.Category as cats cumalative count bugs.Bug.categories %}
{% for node, structure in cats|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
<a href="/categories/{{node.slug}}">{{ node }...
I have the same code on localhost and on server (thanks to mercurial), but it works a little bit different. I want to render category and its subcategories in template using this code:
views.py:
def category(request, category_slug):
try:
category = Category.objects.get(slug=category_slug)
except:
raise Http404
...