【发布时间】:2019-10-03 12:20:24
【问题描述】:
这个问题可能很奇怪,但我想检索除用户登录创建的对象之外的对象
好吧,我在我的视图中尝试了这段代码
def getobjects(request):
products=Products.objects.filter(user!= request.user)
但不起作用。
在模型中
class Products(models.Model):
name=models.Charfield()
user=models.ForeignKey(User)
我需要有关正确查询功能的帮助来处理此问题。提前致谢
【问题讨论】:
-
听起来你在找exclude
标签: python django django-models django-orm