manytomany上的查询过滤器为空

在Django中,有一种方法可以在许多空的字段上进行过滤或为空。

class TestModel(models.Model):
    name = models.CharField(_('set name'), max_length=200)
    manytomany = models.ManyToManyField('AnotherModel', blank=True, null=True)

print TestModel.objects.filter(manytomany__is_null=True)

print TestModel.objects.filter(manytomany=None)
链接地址: http://www.djcxy.com/p/6585.html

上一篇: query filter on manytomany is empty

下一篇: How can I filter a date of a DateTimeField in Django?