Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the filter in django to reflect not equal to?

I have the following filter:

open_slots = Opening.objects.filter(club_id=club_id, day=datetime.date.today(), reservation ='Open')

I want to create another list "closed_slots" that has all the same attributes as the above except that reservation is not equal to 'Open'. When I tried using reservation !='Open' I get an error. How do I fix this?

like image 861
sharataka Avatar asked May 22 '12 06:05

sharataka


1 Answers

Use the exclude method. Details here.

open_slots = Opening.objects.filter(club_id=club_id, day=datetime.date.today()).exclude(reservation ='Open')
like image 160
shanyu Avatar answered Nov 15 '22 23:11

shanyu