Django查询相关对象
我有这样的模型:
class A(Model):
....
class B(Model):
a = ForeignKey(A, related_name="bbb")
class C(Model)
b = ForeignKey(B, related_name="ccc")
file = FileField( ... , null=True, blank=True)
在模板或视图中,如果与 A 相关的某个 C 对象具有 file=None (null) ,我需要标记 A 行。 谢谢。
I have models like this:
class A(Model):
....
class B(Model):
a = ForeignKey(A, related_name="bbb")
class C(Model)
b = ForeignKey(B, related_name="ccc")
file = FileField( ... , null=True, blank=True)
In template or in view I need a mark A row, if some C object related to A has file=None (null) .
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,请尝试以下操作:
OR
OR
如果您省略相关名称,请使用 b_set 和 c_set。
If I understand correctly, try this:
OR
OR
If you leave off the related name, use b_set and c_set.