dana
dana

Reputation: 5208

Django filter bool not iterable

I want to filter all Relation Objects where (relation= following relation in a virtual community) the date one has initiated the following is in the past, related to the moment now.

The following declaration seems to be wrong, as a bool object is not iterable. Is there another way to do that?

d = Relations.objects.filter(date_follow < datetime.now())

Upvotes: 4

Views: 2318

Answers (2)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798686

It's in the docs.

d = Relations.objects.filter(date_follow__lt=datetime.now())

Upvotes: 6

Agos
Agos

Reputation: 19440

Try this:

d = Relations.objects.filter(date_follow__lt=datetime.now())

Relevant documentation here:
http://docs.djangoproject.com/en/dev/ref/models/querysets/#id7

Upvotes: 1

Related Questions