#models.py class Station(models.Model): station_name = models.CharField(max_length=20)
class Order(models.Model): station = models.ManyToManyField(Station, blank=True, null=True) class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) station = models.ManyToManyField(Station, blank=True, null=True) >>> from myapp.models import Station, Order >>> from django.contrib.auth.models import User >>> u = User.objects.get(username__exact='ryan') >>> user_stations = u.get_profile().station.all().values_list('pk', flat=True) >>> user_stations [1L, 2L, 3L] >>> o = Order.objects.filter(station__in=user_stations) >>> o [Too many orders!] Order.objects.filter(station__in=user_stations) returns any order where any of its stations are in user_stations. What I need is only those orders where ALL of its stations are in user_stations. Is there a way to specify __all__in: Order.objects.filter (station__all__in=user_stations) -ryan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---