【发布时间】:2011-05-24 01:08:44
【问题描述】:
models.py:
class Post(models.Model):
msg=models.TextField("Shout it out!:")
college=models.ForeignKey('College')
time=models.DateTimeField(auto_now_add=True)
class Feed(models.Model):
gender = models.CharField(max_length=5, choices=GENDER_CHOICES, default='girl')
location=models.CharField(max_length=25, choices=LOCATION_CHOICES)
msg = models.TextField("Message")
email = models.EmailField("Email:",blank=True, null = True)
college=models.ForeignKey('College')
time=models.DateTimeField(auto_now_add=True)
在模板中,我希望在按时间过滤的流中同时显示提要和帖子。我该怎么做?我们如何按时间过滤两个模型对象?可能吗?需要帮忙。谢谢。
【问题讨论】:
-
所以你想把两者结合起来,然后按时间排序?最后两者都应该显示在一个提要中?
-
两者都出现在同一页面中.. 就像 facebook 新闻提要中的照片、cmets、视频 n al 如何按时间排序一起显示。
-
请参阅下面 Joe J 的回答。在这种情况下,无论如何您都需要一个程序化的解决方案。没有简单的查询可以做这样的事情。
标签: python django django-models django-templates django-views