I have such models:
class LifeGoals(models.Model):
name = models.CharField(max_length=200)
class Interests(models.Model):
name = models.CharField(max_length=200)
class Sports(models.Model):
name = models.CharField(max_length=200)
class UserProfile(models.Model):
name = models.CharField(max_length=50)
life_goals = models.ManyToManyField(LifeGoals, related_name='user_life_goals')
# may be more than 1 choice
interests = models.ManyToManyField(Interests, related_name='user_interests')
# may be more than 1 choice
sports = models.ManyToManyField(Sports, related_name='user_sports')
# may be more than 1 choice
How to write search filter with DjangoORM for such query (for example):
User that has some options in LifeGoals and some options in Interests and some options in Sports
Thanks in advance!!!
I think you can try this:
But everything is well explained here : django doc on queries