django-mptt

show children nodes depending on selected parent

被刻印的时光 ゝ 提交于 2019-12-03 08:35:55
Hi i've been looking all over and can't find the answer to this. I have only 3 months experience in using python/django so excuse my dummy quesion! Im using django mptt to display a simple nested set navigation. <ul class="root"> {% recursetree nodes %} <li> {{ node.name }} {% if not node.is_leaf_node %} <ul class="children"> {{ children }} </ul> {% endif %} </li> {% endrecursetree %} this works fine - however i would like to show only children of the selected category (based on slug) and not all of them. Any ideas ??? i finally did it like this: {% recursetree nodes %} <li> <a href='/{{ node

Django-MPTT full path to child pages how to make?

那年仲夏 提交于 2019-12-03 03:30:00
I'm start using Django-MPTT app to get a tree-based approach on my Django-site pages. For ex. I have pages with sub pages: Trance: Vocal Trance(sub page) Hard Trance(sub page) Breaks: Atmo Breaks(sub page) Progressive Breaks(sub page) How can I get access to them from urls.py? What pattern will help? Do I need to store Full_path in model or it can be done via url pattern? craigds I assume you mean you want to do URLs like this: /trance/ /trance/vocal-trance/ /trance/hard-trace/ /breaks/ /breaks/atmo-breaks/ /breaks/progressive-breaks/ If so, it's probably best to store the url fragment in your

Django-mptt order

梦想与她 提交于 2019-12-03 00:23:21
In my project I am using django-mptt for categories. My model: class Category(models.model): name = models.CharField() parent = models.ForeignKey("self", blank=True, null=True, related_name="sub_category") nav_order = models.IntegerField(null=False, blank=False, default=0) # unsure need nav_order column in DB class Meta: verbose_name_plural = 'Categories' mptt.register(Category) And I need to have ability get order for current category like this: Category Navigation order(one column) CatA 0 |-subcat11 0 |-sub11a 0 |-sub11b 1 \-sub11c 2 \-subcat12 1 CatB 1 |-subcat21 0 |-subcat22 1 \-subcat23 2

Upgrading from Django 1.7.1 to 1.8.2 fails

允我心安 提交于 2019-12-02 09:51:15
My Django 1.7.1 application runs fine. But I would like to upgrade to the more recent version 1.8.2. I'm following the instructions here which basically just say to do pip install -U Django from within my VirtualEnvironment. After I do that line though, I Immediately try to do manage.py and it fails as shown below. Can someone suggest to me what I should do to fix this? The errors below look like they have something to do with the MPTT module. (I'm running version 0.6.1 of MPTT). Upgrading to a newer version of django-mptt as well comes with its own set of messy headaches. (myVirtualEnv) $ .

Including foreign key count in django mptt full tree listing?

这一生的挚爱 提交于 2019-12-01 08:38:50
问题 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 }}</a> {% for level in structure.closed_levels %}</li></ul>{% endfor %} {% endfor %} </div> However, I want to also generate a <span class="count">13</span> for my

Re-ordering child nodes in django-MPTT

蓝咒 提交于 2019-11-30 20:20:43
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] , how can I re-order them to [5, 9, 7, 3] ? I've tried something like this: last_m = MyModel.get(pk = ids.pop(0)) last_m.move_to(last_m.parent, position='first-child') for id in ids: m = MyModel.get(pk = id) m.move_to(last_m, position='right') Which I'd expect to

Django-mptt and multiple parents?

我的梦境 提交于 2019-11-30 19:24:33
I've been banging my head against the desk for a couple weeks on this problem, so I figure it may be time to seek some help. I'm trying to implement a database structure which has hierarchical data of parts for assemblies. My main problem lies with trying to assign one "subassembly" to another "assembly"/tree. Refering to the example trees below- I have no problem creating and working with assembly 1 and 2. But when I make assembly 3, I get multiple objects returned errors when I call up the subassemblies (which I understand base on the way I'm attempting). assembly 1: assembly 2: assembly 3:

How can create a json tree from django-mptt?

社会主义新天地 提交于 2019-11-30 05:13:03
I want to use the JavaScript InfoVis Tooljit ( http://thejit.org ) to render a tree of mptt nodes in django. How can i create the required json structure (see http://thejit.org/static/v20/Jit/Examples/Spacetree/example1.code.html for an example) in django? Thanks If you use the template functionality of django-mptt to generate the JSON data you should be able to do something like the following: var json = {% recursetree nodes %} { id: "{{ node.id }}", name: "{{ node.name }}", data: {}, children: [{{ children }}] }, {% endrecursetree %} The children tag is brilliant, basically calling

Re-ordering child nodes in django-MPTT

坚强是说给别人听的谎言 提交于 2019-11-30 04:32:57
问题 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] , how can I re-order them to [5, 9, 7, 3] ? I've tried something like this: last_m = MyModel.get(pk = ids.pop(0)) last_m.move_to(last_m.parent, position='first

Django-mptt and multiple parents?

对着背影说爱祢 提交于 2019-11-30 03:03:01
问题 I've been banging my head against the desk for a couple weeks on this problem, so I figure it may be time to seek some help. I'm trying to implement a database structure which has hierarchical data of parts for assemblies. My main problem lies with trying to assign one "subassembly" to another "assembly"/tree. Refering to the example trees below- I have no problem creating and working with assembly 1 and 2. But when I make assembly 3, I get multiple objects returned errors when I call up the