Here is one way:
s_date = datetime.strptime('20090106', '%Y%m%d')
e_date = datetime.strptime('20100106', '%Y%m%d')
Activity.objects.filter(timestamp__gte=s_date, timestamp__lte=e_date)
Note that you need to use first strptimeto convert the date of the string to a python object datetime. Second, you need to use the methods gteand ltefor the formation of django request.
source
share