查询另一个模型中不存在的所有对象
我有两个模型,Picture 和 SubmittedPicture,如下所示:
class Picture(models.Model):
user = models.ForeignKey(User)
pic = ImageField(upload_to='userpics/%Y/%m/%d/%H')
class SubmittedPicture(models.Model):
picture = models.ForeignKey(Picture, unique=True)
description = models.TextField()
submitted_time = models.DateTimeField(auto_now_add=True)
现在,我需要查询所有没有相应 SubmittedPicture 的图片。 我尝试了几种选择,但没有一个起作用。
我通读了 Django-doc,但找不到有用的东西。
提前致谢!
I have two models, Picture and SubmittedPicture as follows:
class Picture(models.Model):
user = models.ForeignKey(User)
pic = ImageField(upload_to='userpics/%Y/%m/%d/%H')
class SubmittedPicture(models.Model):
picture = models.ForeignKey(Picture, unique=True)
description = models.TextField()
submitted_time = models.DateTimeField(auto_now_add=True)
Now, I need to query for all Pictures which do not have a corresponding SubmittedPicture.
I tried several options, but none of them was functional.
I read through the Django-doc, but couldn't find something useful.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)