开发者

django manytomany filter question

Hay,

I have a M开发者_StackOverflow社区odel which looks like this

class Person(models.Model):
    name = models.CharField(blank=False, max_length=100)
    friends = models.ManyToManyField('self', blank=True, null=True)

How would i filter out a Person how has friends?

I tried

people_with_friends = Person.objects.filter(friends=True)

but had no luck.

Anyone lend a helping hand?

Thanks


What about this?

people_with_friends = Person.objects.exclude(friends=None)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜