【发布时间】:2011-06-03 20:16:27
【问题描述】:
我正在尝试在视图中检索以下数据:
user_profile 与users 具有一对一连接user_profile 通过stores 字段与store 具有多对多连接store 具有通过targets.store 一对多加入targets
我可以通过以下方式检索与用户关联的所有商店:
user_profile = request.user.get_profile()
all_stores = user_profile.stores.all()
我要检索的是与user_profile 的用户 ID 关联的所有目标,大概是通过all_stores 结果,但我不知道如何到达那里。
【问题讨论】:
-
@S.Lott,是的,但我无法创建查询;我不确定应该如何定义过滤器语句。
标签: python django django-queryset