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?

728x90

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

I found a solution:

foo.objects.filter(range__endswith__isnull = True)

4 months ago