从下面关于 mongodb 的示例中,查找的首选方式是什么:
from djangotoolbox.fields import ListField, EmbeddedModelField
class Post(models.Model):
...
comments = ListField(models.ForeignKey(Comment, related_name="post", null=True, blank=True), null=True, blank=True)
class Comment(models.Model):
text = models.TextField()
created_on = models.DateTimeField()
post_id = 4eaa636b600998598c000018
以下任何一项都不起作用:
posts = post.objects.filter(comments =('text', 'test'))
posts = post.objects.filter(comments =('pk', post_id))
posts = post.objects.filter(comments =('in', post_id))