Home > Enterprise >  How can I query a Postgres DateRange with a single date?
How can I query a Postgres DateRange with a single date?

Time:10-04

I am using django.contrib.postgres.field.DateRangeField as described [here][1].

class MyModel(models.Model):
    date_range = DateRangeField()

How to I query this model to return all date_range with a lower bound greater than today?

I tried:

today = datetime.date.today()
MyModel.objects.filter(date_range__gt=today)

But this results in operator does not exist: daterange > date.

CodePudding user response:

MyModel.objects.filter(date_range__contains=today)

  • Related