Mongedb-da Django-nonrel ro'yxat maydonini qidirish

Quyidagi misolda mongodbda qidirish uchun qanday afzalroq yo'l bo'lishi mumkin:

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  

Quyidagi ishlardan biri:

posts = post.objects.filter(comments =('text', 'test'))
posts = post.objects.filter(comments =('pk', post_id))
posts = post.objects.filter(comments =('in', post_id))
1

1 javoblar

Hozirda ListFieldda ForeignKey uchun juda kam qo'llab-quvvatlanmoqda.

But, I'm working on changing this right now: https://bitbucket.org/emperorcezar/djangotoolbox

Hozirgacha men ishlaydigan narsalarni qo'yishdi. post = Post (izohlar = [comment_obj]) va hozirda qidiruvlar ustida ishlayman.

Umid qilamanki, uni ishga tushirsam va mening so'rovim qabul qilingan bo'lsa, bu yaqin orada qo'llab-quvvatlanadi.

0
qo'shib qo'ydi