:-) ModelB.objects.filter(~Q(modelA__fielddate__range(date1,date2)))
On Tue, Feb 26, 2013 at 10:53 AM, ozgur yilmaz <[email protected]> wrote: > Thanks for the replies. I should use exclude, to find A objects, so > should try this i think: > > ModelB.objects.exclude(modelA__fielddate__range(date1,date2)) > > 2013/2/26 Ronan Foucher <[email protected]>: > > ModelB.objects.filter(modelA__fielddate__range(date1,date2)) > > > > Based on the db backend and the number of column you can add an index on > > fielddate ( check explain output to see if it's useful since it depends > on > > db backend/ dbengine/structure of the table to make it 'inexpensive' ) > > > > ~ Ronan > > > > > > On Tue, Feb 26, 2013 at 9:59 AM, ozgur yilmaz <[email protected]> wrote: > >> > >> Hi, > >> > >> Actually my question is not about the date range. i'm planning to use > >> __lte and __gte filters. My problem is to solve the query (getting A > >> objects using B objects) inexpensively. Thanks anyway, > >> > >> I used: > >> > >> b_objects = B.objects.filter( activity_date__gte = specific_start_date > >> , activity_date__lte = specific_end_date ) > >> > >> a_objects = A.objects.exclude( kisi__in = b_objects ) > >> > >> Is it enough? > >> > >> 2013/2/26 carlos <[email protected]>: > >> > Hi, maybe use DateField__range(date1,date2) > >> > > >> > Cheers > >> > > >> > > >> > On Tue, Feb 26, 2013 at 5:43 AM, ozgur yilmaz <[email protected]> > wrote: > >> >> > >> >> Hi all, > >> >> > >> >> I have to build a query, if possible an inexpensive query: > >> >> > >> >> Model A: > >> >> ... > >> >> ... > >> >> > >> >> Model B: > >> >> ForeignKey( Model A ) > >> >> Date > >> >> ... > >> >> > >> >> Model B is an activity with a date field. I want to find which Model > A > >> >> objects didnt join an activity between specific dates. > >> >> > >> >> What are the appropriate ways to find this result? Any ideas? > >> >> > >> >> Thanks, > >> >> > >> >> -- > >> >> You received this message because you are subscribed to the Google > >> >> Groups > >> >> "Django users" group. > >> >> To unsubscribe from this group and stop receiving emails from it, > send > >> >> an > >> >> email to [email protected]. > >> >> To post to this group, send email to [email protected]. > >> >> Visit this group at > http://groups.google.com/group/django-users?hl=en. > >> >> For more options, visit https://groups.google.com/groups/opt_out. > >> >> > >> >> > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "Django users" group. > >> > To unsubscribe from this group and stop receiving emails from it, send > >> > an > >> > email to [email protected]. > >> > To post to this group, send email to [email protected]. > >> > Visit this group at http://groups.google.com/group/django-users?hl=en > . > >> > For more options, visit https://groups.google.com/groups/opt_out. > >> > > >> > > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups > >> "Django users" group. > >> To unsubscribe from this group and stop receiving emails from it, send > an > >> email to [email protected]. > >> To post to this group, send email to [email protected]. > >> Visit this group at http://groups.google.com/group/django-users?hl=en. > >> For more options, visit https://groups.google.com/groups/opt_out. > >> > >> > > > > > > > > -- > > Cordialement / Best Regards > > > > Ronan FOUCHER > > IS / IT > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/django-users?hl=en. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Cordialement / Best Regards Ronan FOUCHER IS / IT -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.

