Legend123
Legend123

Reputation: 378

Django 1.11 - How do I query a DateTimeRangeField with an upper bound of None (PostgreSQL)

I have the following model:

class foo(models.Model):
    range = DateTimeRangeField()

I want to find all rows where range is unbounded above. I tried the following query:

foo.objects.filter(range__endswith = None)

but it's giving my this exception: ValueError: Cannot use None as a query value. How can I do this?

Upvotes: 3

Views: 606

Answers (1)

Legend123
Legend123

Reputation: 378

I found a solution:

foo.objects.filter(range__endswith__isnull = True)

Upvotes: 2

Related Questions