我有兩種型號:PostType1
,PostType1
。按不同命名的字段排序兩種不同型號
class PostType1(models.Model):
...
created_date = models.DateTimeField(_('created date'), blank=True, null=True)
class PostType2(models.Model):
...
publish_date = models.DateTimeField(_('publish date'), blank=True, null=True)
我做一個查詢既獲得:
posts_type1 = PostType1.objects.all()
posts_type2 = PostType2.objects.all()
我知道如何把它們連:
posts = chain(posts_type1,posts_type2)
我正在尋找一種方式按日期降序對它們進行排序。
這可能嗎?或者我應該看看生sql?
我試圖做同樣的事情,但我排序的參數有點笨拙,不會說錯。非常感謝你。 – geros