I have 2 models:
Pages
------------
Page User
S500 John
Gimp John
WoW John
Subscriptions
------------
Page User
S500 John
So Page field in Subs model is an FK to Pages model. I am trying to return a queryset that will display all the pages belonging to John that doesn’t have a subscription belonging to him.
I tried something like:
fbpages = Page.objects.filter(user='John').exclude(id__in=[Page.id for Page in Page.subscriptions.filter(Page=Page)])
I think I’m close but I’m not sure where I’m going wrong with that query.
I did something like:
current_subs = Subscriptions.objects.filter(user='John')
pages = Page.objects.filter(user='John').exclude(id__in=[subs.Page.id for subs in current_subs])
which works but how do I combine it into 1 query?
1 Answer