[Django]-Exclude by object in queryset

3👍

It seems that my approach is one of the best, so far. Here’s what I’ve ended up with:

pages = [page1, page2] # page1 and page2 are Page objects
Page.objects.filter(site=site).exclude(pk__in=[p.pk for p in pages])

Leave a comment