0
我使用递归外键创建以下类。问题和答案存储在同一个表中。
问题,类型=“Q”
答案类型=“A”以递归关系对相关记录进行排序
余万TOT排序在DESC,那里的依赖答案在ASC顺序来按日期排序的问题。我该怎么做在Django?
class Talk(models.Model):
user = models.ForeignKey(User)
destination = models.ForeignKey(Destination)
text = models.TextField()
type = models.CharField(max_length=30)
sup = models.ForeignKey('self', blank=True, null=True, related_name='child')
created_dt = models.DateTimeField(auto_now_add=True)
thumb_up = models.IntegerField()
thumb_down = models.IntegerField()
class Meta:
ordering = ["-created_dt"]
好笑,这似乎工作中,我有{%for talk_child in talk.child.all%}。似乎talk.child.order_by('created_dt')在视图中不受支持。有什么办法吗? – Elisa 2011-04-29 10:50:12