[英]Finding all posts without tags in Django Postgres ArrayField
Just like what my title says, I want to see all my posts without any tags. 就像我的标题说的一样,我想查看所有没有任何标签的帖子。 However none of the following ORM is working: 但是,以下ORM均不起作用:
x = PostTagging.obejcts.filter(tags=[])
x = PostTagging.objects.filter(tags__len=0)
All I get as a return is: 我得到的回报是:
<QuerySet []>
Here is my model: 这是我的模型:
class PostTagging(models.Model):
title = models.CharField(max_length=50)
tags = ArrayField(models.CharField(max_length=200), blank=True, null=True)
def __unicode__(self):
return self.title
Here is my ORM for creating the blank tag: 这是我用于创建空白标签的ORM:
PostTagging.objects.create(title='Fifth Post')
PostTagging.objects.filter(tags__isnull=True)
是最好的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.