Hello, I have this 2 models: class TimeInterval(models.Model): start = models.TimeField() stop = models.TimeField(null=True, blank=True)
class Day(models.Model): day = models.CharField(maxlength=2) timeintervals = models.ManyToManyField(TimeInterval) I fill it with some data: t1=TimeInterval(start=time(8), stop=time(18)) t1.save() t2=TimeInterval(start=time(8), stop=time(12)) t2.save() t3=TimeInterval(start=time(13), stop=time(18)) t3.save() d1=Day(day='mo') d1.save() d1.timeintervals.add(t1) d2=Day(day='th') d2.save() d2.timeintervals.add(t2, t3) So we have defined: * Monday with timeinterval 8-18 * Thursday with timeintervals 8-12 and 13-18 Now, I would like wrote query, which will fetch only Thursday. I try: Day.objects.filter(day='th', timeintervals__in=[t2, t3]) I suppose, that I get one objects, which accomplish all given parameters. But I get list of two (first match condition day='th' and timeinterval=t2, second match day='th' and timeinterval=t3). Is there any way to write query, which will fetch from DB only "d2" (object which accomplish all given filter parameters -- something like day='th' and "one-timeinterval"=t2 and "next-timeinterval"=t3)? Regards Michal --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---