Order_insertion_by descending order?

I am trying to use the mptt library for a simple nested comment system.

My model

class Comment(MPTTModel): event = models.ForeignKey(Event) author = models.CharField(max_length=60) comment = models.TextField() added = models.DateTimeField(default=timezone.now()) parent = TreeForeignKey('self', null=True, blank=True, related_name='children') class MPTTMeta:order_insertion_by = ['added'] 

Right now, if I use the template tag {% recursetree nodes%}, it displays nodes in increasing time based on "added". I want to display root notes in descending order of time, latest comments. I tried sorting the nodes so that they descend, but the recursetree does not match this order. Is there a way to indicate a descending order? I tried ['-added'], but it does not work.

+4
source share
1 answer

Download the updated version of django-mptt from github - it will allow you to use the descending order the way you want. For instance:

 class Comment(MPTTModel): event = models.ForeignKey(Event) author = models.CharField(max_length=60) comment = models.TextField() added = models.DateTimeField(default=timezone.now()) parent = TreeForeignKey('self', null=True, blank=True, related_name='children') class MPTTMeta: order_insertion_by = ['-added'] 
0
source

All Articles