Answer the question
In order to leave comments, you need to log in
Why doesn't sorting work in django templates?
There are two classes:
class TreeNode(MPTTModel):
contract_date = models.DateField(null=False, blank=False)
parent = TreeForeignKey('self', verbose_name='родитель', null=True, blank=True, related_name='children')
class Meta:
ordering = ['contract_date']
class ClientToCompanyPayment(models.Model):
total = models.PositiveIntegerField(verbose_name='Сумма платежа', blank=False, null=False)
date = models.DateField(verbose_name='Дата платежа', blank=False)
client = models.ForeignKey(TreeNode, verbose_name='Участник', related_name="filterpayments")
class Meta:
abstract = True
class CashPayment(ClientToCompanyPayment):
class Meta:
ordering = ['date']
{% for payment in user.treenode.filterpayments.all %} (возвращает объекты типа CashPayment)
{% for child1 in user.treenode.children.all %}
Answer the question
In order to leave comments, you need to log in
I remember that in MPTTModel it was required to specify a certain ordering value . It seems by tree_id and lft .
I wouldn't bother; you can make the procedure ordered_children in the model, which displays the necessary elements and in the right order, and call it from the template.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question