How can I write this query in Django? (datetime)
Posted
by alex
on Stack Overflow
See other posts from Stack Overflow
or by alex
Published on 2010-03-31T08:37:24Z
Indexed on
2010/03/31
8:43 UTC
Read the original article
Hit count: 350
| time_before | datetime | YES | MUL | NULL | |
| time_after | datetime | YES | MUL | NULL | |
the_tag = Tag.objects.get(id=tag_id)
Log.objects.filter(blah).extra(where=['last_updated >'+the_tag.time_before, 'last_updated' < the_tag.time_after])
Ok. Basically, I have an object that's called "the_tag". I want to select from Log where log.last_updated (which is a datetime field) is between the tag's time. But, I don't know how to write the last part of this Django query.
© Stack Overflow or respective owner