开发者

Django filter bool not iterable

开发者 https://www.devze.com 2023-01-03 11:16 出处:网络
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.

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 = Relatio开发者_运维技巧ns.objects.filter(date_follow < datetime.now())


It's in the docs.

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


Try this:

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号