我有 2 个课程(我正在使用 Flask-mongoengine):
class ArticleCategory(db.Document):
name = db.StringField(verbose_name='Title', required=True, unique=True)
desc = db.StringField(verbose_name='Slug', required=True)
class Article(CreateUpdateMixin, DeletedMixin, db.Document):
title = db.StringField(verbose_name='Title', required=True)
slug = db.StringField(verbose_name='Slug', required=True, unique=True)
content = db.StringField(verbose_name='Content', required=True)
#Many-to-many relation
categories = db.ListField(db.ReferenceField(ArticleCategory),
verbose_name='Category', required=True)
def __unicode__(self):
return self.title
现在我想按特定类别(或类别名称)获取所有文章。__eq
我在 mongoengine 查询帮助中找不到运算符。
操作员Article.objects(categories__in('some_category'))
失败。