Skip to content

Instantly share code, notes, and snippets.

@sanjaykrishnan
Created October 15, 2018 04:35
Show Gist options
  • Save sanjaykrishnan/941f302d75e1195e6b83422fc33e3fa3 to your computer and use it in GitHub Desktop.
Save sanjaykrishnan/941f302d75e1195e6b83422fc33e3fa3 to your computer and use it in GitHub Desktop.
filtering by excluding a type of objects
from myapp.models import Entry
from django.db.models import Q
Entry.objects.filter(~Q(id = 3))
#[<Entry: Entry object>, <Entry: Entry object>, <Entry: Entry object>, ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment