How to get obj from a start_data and a end_data using Django?
I have a table named location
, and I want to get some data between two dates.
I use this:
location.objects.filter(time>start_data, time<end_data)
but I think maybe 开发者_运维知识库not right.
What can I do using django? Thanks!
in addition to sushanath's answer, you can also use the date range lookup http://docs.djangoproject.com/en/dev/ref/models/querysets/#range
location.objects.filter(pub_date__range=(start_date, end_date))
You can use date_gte date_lte django
location.objects.filter(time__gte=2011-03-01,time__lte=2011-03-05)
精彩评论