Hi all,

I'm writing a django app and need help with filtering results from DB.

There is a conference room and it's usage is stored in django model.
There is a field "start_time" (model.TimeField); no "end_time". When I
query the table with a time range (i.e. 3pm - 5pm) I would like to get
not only events that start within given time range, but also the one
currently running (the last one that started before 3pm).

The only solution I have in my mind at the moment is to have two
queries: one would return events starting within the range, other
would retrieve events before that, would sort them descending by time
and I'd get just the first row. Then I'd try to join these two
results.

Although the above algorithm would/should work, I was wondering if
there was more elegant way to this?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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