开发者

How to exclude manytomany object in query?

I created my own manager:

class DataManager(models.Manager):

    def optfilter(self, options = dict()):

    kwargs = dict()
    if options.has_key('active'):
        kwargs['active__id'] = options['active']

    return self.filter(**kwargs)

active is ManyToMany field.

and it working exacly as I want. But what about when I want exclude object from filte开发者_开发问答r? Something like this:

kwargs['exclude_active_id'] = options['active']


Same idea as you're already implemented except use exclude instead of filter

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜