alias51
alias51

Reputation: 8648

How can I query a Postgres DateRange with a single date?

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.

Upvotes: 0

Views: 392

Answers (1)

lucutzu33
lucutzu33

Reputation: 3700

MyModel.objects.filter(date_range__contains=today)

Upvotes: 2

Related Questions