开发者

Django Query Filter

开发者 https://www.devze.com 2023-03-13 08:56 出处:网络
The following line in my view selects all records that have a delay of 0 t = Times.objects.filter(delay = 0)

The following line in my view selects all records that have a delay of 0

t = Times.objects.filter(delay = 0)

How do i write it such that it selects everyt开发者_运维百科hing but with delay 0?


Can you try doing?

t = Times.objects.exclude(delay=0)

I think that will work for you.

Hope that helps, Joe


With exclude() instead.


Use the exclude() method instead of the filter() method

https://docs.djangoproject.com/en/1.3/topics/db/queries/#retrieving-specific-objects-with-filters


It's in the docs. You want:

t = Times.objects.filter(delay__ne=0)

0

精彩评论

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