django filter by datetime on a range of dates

后端 未结 5 1097
我寻月下人不归
我寻月下人不归 2021-01-01 23:55

I have a model with field \"created_at\", and I have a list of dates. So, I want to get all the models that are created in the date range. How ?

I know that we ca

5条回答
  •  滥情空心
    2021-01-02 00:39

    You can use __gte (greater than or equal) and __lte (less than or equal). For example:

    queryset.filter(created_at__gte=datetime.date.today())
    

提交回复
热议问题