I have two model: Content and Tag that have ManyToMany realationship
Content(models.Model):
tags = models.ManyToManyField(Tag,
null=False,
blank=False,
related_name="tags")
Tag(models.Model):
slug = models.CharField(max_length=255, null=False, blank=False, unique=True)
name = models.CharField(max_length=255, null=False, blank=False, unique=True)
Notice that I'm using MongoDB and djongo connector to work with my db.
Now I want to filter "All of content that have n specific tags", example: all of the content that have tags = ["Movie", "News", "Science"], suppose id of them is: 1, 2, 3 corresponding.
I have used chaining filter.
content.objects.filter(tags=1).filter(tags=2).filter(tags=3)
but it return not found.
Yep, of course contents that have id = [1, 2, 3] are available in my database.
But when I migrate to MySQL and try again, it work and return a queryset that I expected.