Query datetime by today's date in Django

前端 未结 7 511
梦谈多话
梦谈多话 2021-01-31 08:16

I\'m saving datetime in the db for an object. I\'d like to query against the db and select anything from todays date, not datetime.

What\'s the

7条回答
  •  暖寄归人
    2021-01-31 08:45

    You can also do something like this:

    today = date.today()
    invoice_for_today = Invoice.objects.filter(date__year=today.year, date__month=today.month, date__day=today.day)
    

提交回复
热议问题