Hello list, 

I have a little trouble setting up a Django query. In my app the user logs time 
spans by entering two time points. I want to make sure that a time span logged 
is not within another span already entered. 
Example: ONE goes from 1000 to 1200, TWO goes from 1400 to 1600. Now I want 
users to be able to log 1300 to 1330, but NOT 1155 to 1300, or 1300 to 1500. 

for that I have a query which should give me the last logged time span (called 
"leg"):
        . span_before = 
Leg.objects.filter(start__lte=newly_entered_start_date).order_by('start')[:1]
(all with datetime objects of course)

That works … almost. If I enter the same information twice, I get actually 
ALWAYS the leg before, although using "lte". Example: ONE and TWO are already 
entered. I log TWO again, by accident. Now I expect that my query, which looks 
like … : 
        . span_before = 
Leg.objects.filter(start__lte=1400).order_by('start')[:1]
… returns the leg actually starting at 1400 (ltEQUAL, right?), but it does not, 
it returns ONE (the leg starting at 1200). 

Does anyone know why?


Django 1.3, SQLite for now. 


Thanks & greetings, 
Axel.

-- 
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