Hello django-users,

I'm having some trouble with a date-range filter.
My goal is to prevent a model from being saved when it's date-range
overlaps with existing records.

Apparently, the math is quite straightforward:

( start1 <= end2 and start2 <= end1 )

if TRUE, the ranges overlap (*)


Still, I can't get it to work. Am I doing it wrong?
I've tried some combinations, such as:

SomeModel.objects.filter( Q(time_start__lte=self.time_end) & Q
(time_end__gte=self.time_end)   ).count()

Thanks for any help or hints.

Gijs


(* http://c2.com/cgi/wiki?TestIfDateRangesOverlap)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to