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

django, equals, filter, view

Solution

Use the `exclude` method. Details here.

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

Problem

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?

Original source

Related problems