【发布时间】:2009-08-10 18:17:02
【问题描述】:
我有以下问题:
我的应用程序有 2 个模型:
1)
class ActiveList(models.Model):
user = models.ForeignKey(User, unique=True)
updatedOn = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.user.username
'''
GameClaim class, to store game requests.
'''
class GameClaim(models.Model):
me = models.ForeignKey(ActiveList, related_name='gameclaim_me')
opponent = models.ForeignKey(ActiveList, related_name='gameclaim_opponent')
在我看来,我将所有 ActiveList 对象 all = ActiveList.objects.all() 传递给模板
在模板中,我遍历 ActiveList 中的每个项目,并创建一个用于我的客户端应用程序的 xml 文件。
问题是:
如何查询一个用户(例如测试,ActiveList 的一部分)对处于循环中的用户所做的声明的信息
user2 例如是这样拍摄的
{% for item in activeList %}
{% endfor %}
在这种情况下,用户 2 是一个项目
【问题讨论】: