如何以标准方式(不使用原始SQL)创建此类查询?
然后,我需要添加更多条件。
例如
class Post( models.Model ):
title = models.CharField( max_length = 128 )
text = models.TextField()
class Comment( models.Model ):
post = models.ForeignKey( Post )
text = models.TextField()
指定comment
有None
:
Post.objects.filter(comment=None)
您可以使用添加filter
或来添加更多条件exclude
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句